Precision?

Terry Reedy tjreedy at udel.edu
Sun May 15 14:54:12 EDT 2005


"Steffen Glückselig" <usenet at gungfu.de> wrote in message 
news:1116165159.269252.117830 at g14g2000cwa.googlegroups.com...
>>>> 1.0 + 3.0 + 4.6
> 8.5999999999999996
>
> Ehm, how could I get the intuitively 'correct' result of - say - 8.6?

>>> str(1.0+4.6+3.0)
'8.6'

See Lib Ref 2, Builtin functs, repr() and str(), Lan Ref (or tutorial) 
section on % formating, and probably a few FAQ entries.

Terry J. Reedy






More information about the Python-list mailing list