Package orm2 :: Package util :: Module fixedpoint
[hide private]
[frames] | no frames]

Module fixedpoint

source code

Classes [hide private]
  object
  FixedPoint
Basic FixedPoint object class,...

Functions [hide private]
  bankersRounding(self, dividend, divisor, quotient, remainder)
...
  addHalfAndChop(self, dividend, divisor, quotient, remainder)
...
  property(x, y)
  _tento(n, cache={})
Cached computation of 10**n...
  _norm(x, y, isinstance=<built-in function isinstance>, FixedPoint=<class 'orm2.util.fixedpoint.FixedPoint'>, _tento=<function _tento at 0x77b5f0>)
Return xn, yn, p s.t.
  _mkFP(n, p, FixedPoint=<class 'orm2.util.fixedpoint.FixedPoint'>)
Make FixedPoint objext - Return a new FixedPoint object with the selected precision.
  _parser(...)
  _string2exact(s)
Return n, p s.t.
  _test()
Unit testing framework...

Variables [hide private]
  __copyright__ = 'Copyright (C) Python Software Foundation'
  __author__ = 'Tim Peters'
  __version__ = (0, 1, 0)
  DEFAULT_PRECISION = 2

Function Details [hide private]

bankersRounding(self, dividend, divisor, quotient, remainder)

source code 

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

addHalfAndChop(self, dividend, divisor, quotient, remainder)

source code 

the equivalent of 'add half and chop'
increment the quotient if
     the remainder is greater than half of the divisor
  or the remainder is exactly half the divisor and the quotient is >= 0

property(x, y)

source code 
None

_tento(n, cache={})

source code 
Cached computation of 10**n

_norm(x, y, isinstance=<built-in function isinstance>, FixedPoint=<class 'orm2.util.fixedpoint.FixedPoint'>, _tento=<function _tento at 0x77b5f0>)

source code 
Return xn, yn, p s.t.
   p = max(x.p, y.p)
   x = xn / 10**p
   y = yn / 10**p

x must be FixedPoint to begin with; if y is not FixedPoint,
it inherits its precision from x.

Note that this method is called a lot, so default-arg tricks are helpful.

_mkFP(n, p, FixedPoint=<class 'orm2.util.fixedpoint.FixedPoint'>)

source code 
Make FixedPoint objext - Return a new FixedPoint object with the selected precision.

_parser(...)

 
None

_string2exact(s)

source code 
Return n, p s.t. float string value == n * 10**p exactly.

_test()

source code 
Unit testing framework


Variables Details [hide private]

__copyright__

None
Value:
'Copyright (C) Python Software Foundation'                             
      

__author__

None
Value:
'Tim Peters'                                                           
      

__version__

None
Value:
(0, 1, 0)                                                              
      

DEFAULT_PRECISION

None
Value:
2