| Trees | Indices | Help |
|
|---|
|
|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
|
precision Return the precision of this FixedPoint. |
|||
| n | |||
| p | |||
|
Inherited from |
|||
|
|||
|
Return the precision of this FixedPoint. The precision is the number of decimal digits carried after the decimal point, and is an int >= 0. |
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. |
|
|
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.
|
|
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
|
Return fractional portion as a FixedPoint. x.frac() + long(x) == x |
|
rounding via nearest-even
increment the quotient if
the remainder is more than half of the divisor
or the remainder is exactly half the divisor and the quotient is odd
|
|
|||
precisionReturn the precision of this FixedPoint. The precision is the number of decimal digits carried after the decimal point, and is an int >= 0.
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu Aug 5 14:59:38 2010 | http://epydoc.sourceforge.net |