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

Public Member Functions

def __abs__ (self)
 
def __add__ (self, other)
 
def __cmp__ (self, other)
 
def __deepcopy__ (self, memo)
 
def __div__ (self, other)
 
def __divmod__ (self, other)
 
def __float__ (self)
 
def __hash__ (self)
 
def __init__ (self, value=0, precision=DEFAULT_PRECISION)
 
def __int__ (self)
 
def __long__ (self)
 
def __mod__ (self, other)
 
def __mul__ (self, other)
 
def __neg__ (self)
 
def __nonzero__ (self)
 
def __rdiv__ (self, other)
 
def __rdivmod__ (self, other)
 
def __repr__ (self)
 
def __rmod__ (self, other)
 
def __rsub__ (self, other)
 
def __str__ (self)
 
def __sub__ (self, other)
 
def copy (self)
 
def frac (self)
 
def get_precision (self)
 
def set_precision (self, precision=DEFAULT_PRECISION)
 

Public Attributes

 n
 
 p
 

Properties

 precision = property(get_precision, set_precision)
 

Private Member Functions

def __reduce (self)
 
def _roundquotient (self, x, y)
 

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

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.

def pyclearsilver.fixedpoint.FixedPoint.get_precision (   self)
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.

Member Data Documentation

pyclearsilver.fixedpoint.FixedPoint.__copy__ = copy
staticprivate

Definition at line 310 of file fixedpoint.py.

pyclearsilver.fixedpoint.FixedPoint.__radd__ = __add__
staticprivate

Definition at line 355 of file fixedpoint.py.

pyclearsilver.fixedpoint.FixedPoint.__rmul__ = __mul__
staticprivate

Definition at line 370 of file fixedpoint.py.

list pyclearsilver.fixedpoint.FixedPoint.__slots__ = ['n', 'p']
staticprivate

Definition at line 169 of file fixedpoint.py.

pyclearsilver.fixedpoint.FixedPoint.n

Definition at line 171 of file fixedpoint.py.

pyclearsilver.fixedpoint.FixedPoint.p

Definition at line 171 of file fixedpoint.py.

Property Documentation

pyclearsilver.fixedpoint.FixedPoint.precision = property(get_precision, set_precision)
static

Definition at line 290 of file fixedpoint.py.


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


pyclearsilver
Author(s): Scott Noob Hassan
autogenerated on Mon Jun 10 2019 15:51:13