Public Member Functions | Public Attributes | Properties | Private Member Functions | Static Private Attributes
pyclearsilver.fixedpoint.FixedPoint Class Reference
Inheritance diagram for pyclearsilver.fixedpoint.FixedPoint:
Inheritance graph
[legend]

List of all members.

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']

Detailed Description

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.


Constructor & Destructor Documentation

def pyclearsilver.fixedpoint.FixedPoint.__init__ (   self,
  value = 0,
  precision = DEFAULT_PRECISION 
)

Definition at line 170 of file fixedpoint.py.


Member Function Documentation

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.

Definition at line 312 of file fixedpoint.py.

def pyclearsilver.fixedpoint.FixedPoint.__div__ (   self,
  other 
)

Definition at line 372 of file fixedpoint.py.

Definition at line 385 of file fixedpoint.py.

Return the floating point representation of this FixedPoint. 
    Caution! float can lose precision.

Definition at line 405 of file fixedpoint.py.

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.

Return integer value of FixedPoint object.

Definition at line 423 of file fixedpoint.py.

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.

Definition at line 340 of file fixedpoint.py.

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.

Definition at line 394 of file fixedpoint.py.

Return n, p s.t. self == n/10**p and n % 10 != 0

Definition at line 445 of file fixedpoint.py.

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.

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.

Definition at line 307 of file fixedpoint.py.

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.

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.


Member Data Documentation

Definition at line 310 of file fixedpoint.py.

Definition at line 355 of file fixedpoint.py.

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.


Property Documentation

Definition at line 290 of file fixedpoint.py.


The documentation for this class was generated from the following file:


pyclearsilver
Author(s): Scott Hassan/hassan@willowgarage.com
autogenerated on Wed Apr 23 2014 10:35:42