Working with decimal points

mtallen at gmail.com mtallen at gmail.com
Sat Apr 8 12:55:04 EDT 2006


Byte wrote:
> That dosnt work either:
>
> sum = 0.1+1/4
> print sum
>
> Just returns 0.1

You get precedence right? Your equation does not evaluate from left to
right. 1/4 happens first, and since there are no floats you get 0.

in that equation you basically are doing this:

sum = 1/4
print sum
0

sum = 0.1 + sum
print sum
0.1




More information about the Python-list mailing list