usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Mon Jan 8 23:20:45 CET 2007
Rory Campbell-Lange wrote:
> Is using the decimal module the best way around this? (I'm
> expecting the first sum to match the second). It seem
> anachronistic that decimal takes strings as input, though.
What's your problem with the result, or what's your goal? Such
precision errors with floating point numbers are normal because the
precision is limited technically.
For floats a and b, you'd seldom say "if a == b:" (because it's
often false as in your case) but rather
"if a - b < threshold:" for a reasonable threshold value which
depends on your application.
Also check the recent thread "bizarre floating point output".
BOFH excuse #333:
A plumber is needed, the network drain is clogged
More information about the Python-list