$search
Classes | |
class | FixedPoint |
class | object |
Functions | |
def | _mkFP |
def | _norm |
def | _string2exact |
def | _tento |
def | _test |
def | addHalfAndChop |
def | bankersRounding |
def | property |
Variables | |
string | __author__ = "Tim Peters" |
string | __copyright__ = "Copyright (C) Python Software Foundation" |
int | __version__ = 0 |
tuple | _parser = re.compile(r""" \s* (?P<sign>[-+])? ( (?P<int>\d+) (\. (?P<frac>\d*))? | \. (?P<onlyfrac>\d+) ) ([eE](?P<exp>[-+]? \d+))? \s* $""", re.VERBOSE) |
int | DEFAULT_PRECISION = 2 |
def pyclearsilver::fixedpoint::_mkFP | ( | n, | ||
p, | ||||
FixedPoint = FixedPoint | ||||
) | [private] |
Make FixedPoint objext - Return a new FixedPoint object with the selected precision.
Definition at line 495 of file fixedpoint.py.
def pyclearsilver::fixedpoint::_norm | ( | x, | ||
y, | ||||
isinstance = isinstance , |
||||
FixedPoint = FixedPoint , |
||||
_tento = _tento | ||||
) | [private] |
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.
Definition at line 468 of file fixedpoint.py.
def pyclearsilver::fixedpoint::_string2exact | ( | s | ) | [private] |
Return n, p s.t. float string value == n * 10**p exactly.
Definition at line 527 of file fixedpoint.py.
def pyclearsilver::fixedpoint::_tento | ( | n, | ||
cache = {} | ||||
) | [private] |
Cached computation of 10**n
Definition at line 460 of file fixedpoint.py.
def pyclearsilver::fixedpoint::_test | ( | ) | [private] |
Unit testing framework
Definition at line 560 of file fixedpoint.py.
def pyclearsilver::fixedpoint::addHalfAndChop | ( | self, | ||
dividend, | ||||
divisor, | ||||
quotient, | ||||
remainder | ||||
) |
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
Definition at line 138 of file fixedpoint.py.
def pyclearsilver::fixedpoint::bankersRounding | ( | self, | ||
dividend, | ||||
divisor, | ||||
quotient, | ||||
remainder | ||||
) |
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
Definition at line 125 of file fixedpoint.py.
def pyclearsilver::fixedpoint::property | ( | x, | ||
y | ||||
) |
Definition at line 157 of file fixedpoint.py.
string pyclearsilver::fixedpoint::__author__ = "Tim Peters" |
Definition at line 122 of file fixedpoint.py.
string pyclearsilver::fixedpoint::__copyright__ = "Copyright (C) Python Software Foundation" |
Definition at line 121 of file fixedpoint.py.
Definition at line 123 of file fixedpoint.py.
tuple pyclearsilver::fixedpoint::_parser = re.compile(r""" \s* (?P<sign>[-+])? ( (?P<int>\d+) (\. (?P<frac>\d*))? | \. (?P<onlyfrac>\d+) ) ([eE](?P<exp>[-+]? \d+))? \s* $""", re.VERBOSE) |
Definition at line 512 of file fixedpoint.py.
Definition at line 162 of file fixedpoint.py.