Public Member Functions | |
def | __abs__ |
def | __add__ |
def | __cmp__ |
def | __deepcopy__ |
def | __div__ |
def | __divmod__ |
def | __float__ |
def | __hash__ |
def | __init__ |
def | __int__ |
def | __long__ |
def | __mod__ |
def | __mul__ |
def | __neg__ |
def | __nonzero__ |
def | __rdiv__ |
def | __rdivmod__ |
def | __repr__ |
def | __rmod__ |
def | __rsub__ |
def | __str__ |
def | __sub__ |
def | copy |
def | frac |
def | get_precision |
def | set_precision |
Public Attributes | |
n | |
p | |
Properties | |
precision = property(get_precision, set_precision) | |
Private Member Functions | |
def | __reduce |
def | _roundquotient |
Static Private Attributes | |
__copy__ = copy | |
__radd__ = __add__ | |
__rmul__ = __mul__ | |
list | __slots__ = ['n', 'p'] |
Basic FixedPoint object class, The exact value is self.n / 10**self.p; self.n is a long; self.p is an int
Definition at line 164 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__init__ | ( | self, | |
value = 0 , |
|||
precision = DEFAULT_PRECISION |
|||
) |
Definition at line 170 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__abs__ | ( | self | ) |
Returns new FixedPoint containing the absolute value of this FixedPoint
Definition at line 343 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__add__ | ( | self, | |
other | |||
) |
Definition at line 350 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__cmp__ | ( | self, | |
other | |||
) |
Definition at line 315 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__deepcopy__ | ( | self, | |
memo | |||
) |
Definition at line 312 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__div__ | ( | self, | |
other | |||
) |
Definition at line 372 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__divmod__ | ( | self, | |
other | |||
) |
Definition at line 385 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__float__ | ( | self | ) |
Return the floating point representation of this FixedPoint. Caution! float can lose precision.
Definition at line 405 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__hash__ | ( | self | ) |
Caution! == values must have equal hashes, and a FixedPoint is essentially a rational in unnormalized form. There's really no choice here but to normalize it, so hash is potentially expensive. n, p = self.__reduce() Obscurity: if the value is an exact integer, p will be 0 now, so the hash expression reduces to hash(n). So FixedPoints that happen to be exact integers hash to the same things as their int or long equivalents. This is Good. But if a FixedPoint happens to have a value exactly representable as a float, their hashes may differ. This is a teensy bit Bad.
Definition at line 319 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__int__ | ( | self | ) |
Return integer value of FixedPoint object.
Definition at line 423 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__long__ | ( | self | ) |
EJG/DF - Should this round instead? Note e.g. long(-1.9) == -1L and long(1.9) == 1L in Python Note that __int__ inherits whatever __long__ does, and .frac() is affected too
Definition at line 412 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__mod__ | ( | self, | |
other | |||
) |
Definition at line 398 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__mul__ | ( | self, | |
other | |||
) |
Definition at line 365 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__neg__ | ( | self | ) |
Definition at line 340 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__nonzero__ | ( | self | ) |
Returns true if this FixedPoint is not equal to zero
Definition at line 336 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__rdiv__ | ( | self, | |
other | |||
) |
Definition at line 381 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__rdivmod__ | ( | self, | |
other | |||
) |
Definition at line 394 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__reduce | ( | self | ) | [private] |
Return n, p s.t. self == n/10**p and n % 10 != 0
Definition at line 445 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__repr__ | ( | self | ) |
Definition at line 304 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__rmod__ | ( | self, | |
other | |||
) |
Definition at line 401 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__rsub__ | ( | self, | |
other | |||
) |
Definition at line 362 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__str__ | ( | self | ) |
Definition at line 292 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.__sub__ | ( | self, | |
other | |||
) |
Definition at line 357 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint._roundquotient | ( | self, | |
x, | |||
y | |||
) | [private] |
Divide x by y, return the result of rounding Developers may substitute their own 'round' for custom rounding y must be > 0
Definition at line 434 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.copy | ( | self | ) |
Definition at line 307 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.frac | ( | self | ) |
Return fractional portion as a FixedPoint. x.frac() + long(x) == x
Definition at line 427 of file fixedpoint.py.
Return the precision of this FixedPoint. The precision is the number of decimal digits carried after the decimal point, and is an int >= 0.
Definition at line 257 of file fixedpoint.py.
def pyclearsilver.fixedpoint.FixedPoint.set_precision | ( | self, | |
precision = DEFAULT_PRECISION |
|||
) |
Change the precision carried by this FixedPoint to p. precision must be an int >= 0, and defaults to DEFAULT_PRECISION. If precision is less than this FixedPoint's current precision, information may be lost to rounding.
Definition at line 266 of file fixedpoint.py.
pyclearsilver::fixedpoint.FixedPoint::__copy__ = copy [static, private] |
Definition at line 310 of file fixedpoint.py.
pyclearsilver::fixedpoint.FixedPoint::__radd__ = __add__ [static, private] |
Definition at line 355 of file fixedpoint.py.
pyclearsilver::fixedpoint.FixedPoint::__rmul__ = __mul__ [static, private] |
Definition at line 370 of file fixedpoint.py.
list pyclearsilver::fixedpoint.FixedPoint::__slots__ = ['n', 'p'] [static, private] |
Definition at line 169 of file fixedpoint.py.
Definition at line 170 of file fixedpoint.py.
Definition at line 170 of file fixedpoint.py.
Definition at line 290 of file fixedpoint.py.