By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

Is There the Equivalent of FLT_EPS of C In Python?

P: n/a
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?

Sep 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
follows:
eps = 1.
while 1. + eps != 1.: .... eps /= 2.
.... eps

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

Sep 16 '05 #2

P: n/a
Thank you very much.

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

Sep 16 '05 #3

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

Sep 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.