float point properties access
Robin Becker
robin at SPAMREMOVEjessikat.fsnet.co.uk
Fri Dec 3 09:42:06 EST 2004
Neal D. Becker wrote:
> Is there a way in python to access properties of floats? I need something
> equiv to C DBL_EPSILON defined in <float.h>.
>
>
you could try the traditional algorithm
>>> def dbl_epsilon():
... n = 0
... while 1:
... e = 1.0/2**n
... if (1.0+e==1.0): break
... n += 1
... pe = e
... return pe
...
>>> print dbl_epsilon()
2.22044604925e-016
>>>
--
Robin Becker
More information about the Python-list
mailing list