Public Member Functions | |
def | __init__ |
def | __del__ |
def | __str__ |
def | __repr__ |
def | __eq__ |
def | __ne__ |
def | set_zero |
def | is_zero |
def | set_min |
def | is_min |
def | set_max |
def | is_max |
def | to_int |
def | to_float |
def | to_string |
def | compare |
Decimal type for SequoiaDB decimal is an type of element of bson, for the seak of double(IEEE) usage: >>> import bson >>> from bson import Decimal >>> obj = Decimal("12345.6789098765", 1000, 100) # precision 1000, scale 100 # use a decimal into bson as blow: >>> doc = { 'rest':obj } >>> print (doc) { "$decimal": "12345.6789098765", "$precision": [1000, 10] } >>> doc = { "decimal": doc } when a doc with decimal element encoded to an bson obj, it can be used to insert into SequoiaDB and it also can be decoded into an decimal object from bson object >>> bobj = bson.BSON.encode(doc) >>> dd = bson.BSON.decode(bobj) >>> v = dd['decimal'] >>> v { "$decimal": "12345.6789098765", "$precision": [1000, 10] } >>> type(v) <class 'bson.decimal.Decimal'> methods can be listed by using dir(obj)
def bson.decimal.Decimal.__init__ | ( | self, | |
value, | |||
precision = None , |
|||
scale = None |
|||
) |
create an decimal object, precision and scale are 0 by default and precision is limited under 1000
def bson.decimal.Decimal.compare | ( | self, | |
rhs | |||
) |
compare between two decimal object. if int is specified, int value will be converted to an decimal object, then compare
def bson.decimal.Decimal.is_max | ( | self | ) |
charge the value of decimal is min value or not
def bson.decimal.Decimal.is_min | ( | self | ) |
charge the value of decimal is min value or not
def bson.decimal.Decimal.is_zero | ( | self | ) |
charge the value of decimal is zero ir not
def bson.decimal.Decimal.set_max | ( | self | ) |
set the value of decimal is the max value
def bson.decimal.Decimal.set_min | ( | self | ) |
set the value of decimal is the min value
def bson.decimal.Decimal.set_zero | ( | self | ) |
set the decimal object as an instance initalized by 0
def bson.decimal.Decimal.to_float | ( | self | ) |
force the decimal to be an float(double is supported), and show it regularized by scale
def bson.decimal.Decimal.to_int | ( | self | ) |
force the decimal to be an int(long), and show it regularized by scale
def bson.decimal.Decimal.to_string | ( | self | ) |
force the decimal to be an string, and show it regularized by scale