Possible Duplicate:
Why doesn't this division work in python?
A simple problem I’m having (I Think) The following statement:
print (4950*8)/(((4950*8)/10000000*(1538/1460))+0.1/1000)/1000
Gives me 396000.0.
But on a Calculator I get 9270.614192621.
If someone could point out what I’m doing wrong in the code that would be great.
Thanks.
Old versions of Python use truncated integer division for
intoperands.Try
from __future__ import division(see http://www.python.org/dev/peps/pep-0238/ for the full story) or coerce int operands to float (e.g. withfloat, or by appending.0to literals).