Is There the Equivalent of FLT_EPS of C In Python?
jburgy at gmail.com
Fri Sep 16 13:34:54 CEST 2005
A. L. wrote:
> I am writing the code involved in numerical computation. When I need a
> float epsilon similar to FLT_EPS in C, eps in matlab, I fail to find
> the equivalent in python. Could somebody here can give me some advices?
Have you searched the documentation? I you can't find anything there,
you can always calculate it yourself. Epsilon is usually defined as
>>> eps = 1.
>>> while 1. + eps != 1.:
... eps /= 2.
Then some people actually multiply the above number by 2. In other
words (on my machine), eps is math.ldexp(1, -52). YMMV
More information about the Python-list