Maths error

Rory Campbell-Lange rory at campbell-lange.net
Mon Jan 8 22:30:15 CET 2007


>>> (1.0/10.0)  + (2.0/10.0) + (3.0/10.0)
0.60000000000000009
>>> 6.0/10.0
0.59999999999999998

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.

Help much appreciated;
Rory
-- 
Rory Campbell-Lange 
<rory at campbell-lange.net>
<www.campbell-lange.net>



More information about the Python-list mailing list