Sean Perry wrote:
gerardo arnaez wrote:

On Mon, 28 Mar 2005 09:27:11 -0500, orbitz <[EMAIL PROTECTED]> wrote:

Floats are inherintly inprecise.  So if thigns arn't working like you
expect don't be surprised if 0.15, 0.12, and 0.1 are closer to the same
number than you think.



Are you telling me that I cant expect 2 digit preceision?


Not without using round. Have *NO* faith in floating points. This is especially true when you are creating the decimals via division and the like.

What?!?!

OK, floats don't necessarily have the exact values you expect (they may have errors after many decimal places), and comparing floats for equality is risky business (you should compare for close, not equal). But the errors are well past the two-digit place. See the FAQ for more info on one kind of error:
http://www.python.org/doc/faq/general.html#why-are-floating-point-calculations-so-inaccurate


Note that the original poster was looking at ranges, not looking for exact 
matches!

Can you be more specific about what kinds of problems you have had?

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to