Is There the Equivalent of FLT_EPS of C In Python?

A

A. L.

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?
 
J

jburgy

A. L. said:
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
follows:
.... eps /= 2.
....1.1102230246251565e-16

Then some people actually multiply the above number by 2. In other
words (on my machine), eps is math.ldexp(1, -52). YMMV

Jan
 
A

A. L.

Thank you very much.

I have searched in python's documentation, and I am sure that python
doesn't provide an epsilon.
 
A

A. L.

According to pp 134 of "C: A Reference Manual", it's better to use
eps*2 in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,320
Members
48,004
Latest member
KelseyFors

Latest Threads

Top