real.py

Constant class

Constant provides constant-like behavior for Float calculation context. It caches the constant value and re-computes for more precision by request.

example:

>>> pi = Constant(piGaussLegendre)
>>> print pi
3.14159265358979
>>> pi + 1
4.14159265358979
>>> pi(RelativeError(0,1,2**100)) # for 100 bit precision
3.1415926535897932384626433832795

constructor

Constant(getValue [, err])

The first argument must be a function which computes the constant with an argument specifies error. The second argument can be used to set the default error.

methods

inverse()

Return the inverse of the number.

toRational()

Return a rational number approximating the number.

operators

(err)Return the value at least as accurate as the given error err.

Other operators are delegated to the cached value.


Last-modified: 2005-09-28 (¿å) 13:50:47