Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
decimal._Log10Memoize Class Reference
Inheritance diagram for decimal._Log10Memoize:
Inheritance graph
[legend]
Collaboration diagram for decimal._Log10Memoize:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getdigits

Public Attributes

 digits
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Class to compute, store, and allow retrieval of, digits of the
constant log(10) = 2.302585....  This constant is needed by
Decimal.ln, Decimal.log10, Decimal.exp and Decimal.__pow__.

Definition at line 5689 of file decimal.py.


Constructor & Destructor Documentation

Definition at line 5693 of file decimal.py.

05693 
05694     def __init__(self):
05695         self.digits = "23025850929940456840179914546843642076011014886"

Here is the caller graph for this function:


Member Function Documentation

def decimal._Log10Memoize.getdigits (   self,
  p 
)
Given an integer p >= 0, return floor(10**p)*log(10).

For example, self.getdigits(3) returns 2302.

Definition at line 5696 of file decimal.py.

05696 
05697     def getdigits(self, p):
05698         """Given an integer p >= 0, return floor(10**p)*log(10).
05699 
05700         For example, self.getdigits(3) returns 2302.
05701         """
05702         # digits are stored as a string, for quick conversion to
05703         # integer in the case that we've already computed enough
05704         # digits; the stored digits should always be correct
05705         # (truncated, not rounded to nearest).
05706         if p < 0:
05707             raise ValueError("p should be nonnegative")
05708 
05709         if p >= len(self.digits):
05710             # compute p+3, p+6, p+9, ... digits; continue until at
05711             # least one of the extra digits is nonzero
05712             extra = 3
05713             while True:
05714                 # compute p+extra digits, correct to within 1ulp
05715                 M = 10**(p+extra+2)
05716                 digits = str(_div_nearest(_ilog(10*M, M), 100))
05717                 if digits[-extra:] != '0'*extra:
05718                     break
05719                 extra += 3
05720             # keep all reliable digits so far; remove trailing zeros
05721             # and next nonzero digit
05722             self.digits = digits.rstrip('0')[:-1]
05723         return int(self.digits[:p+1])

Here is the call graph for this function:


Member Data Documentation

Definition at line 5694 of file decimal.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


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