On Tue Nov 14, 2006 at 11:49:53 +1100, Carlo Sogono wrote:
>I'm attempting to learn Python and have been playing around with it for 
>the past few days. Why is my output not too smart:
>
>>>> 8.0 + 0.45
>8.4499999999999993
>
>However this seems ok:
>
>>>> 0.45 + 0.55
>1.0

First you need to read this:

http://www.cs.utah.edu/~zachary/isp/applets/FP/FP.html

Then consider using a decimal/fixed-point type rather than floating point type
if that is what you need. (Hint: if you are dealing with money, you probably 
want
fixed-point).

Benno
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders

Reply via email to