0

The following program goes from -1 to 0, in steps of 0.01 (-1,-.99,-.98,...,-.02,-.01) , then multiplies each one of these terms by 100, and prints the result.

a=-1
c=100
while a<0:
    print "a*c=",a*c,"int(a*c)=",int(a*c)
    a=a+.01

Now, I should be getting the same output for "a * c" and "int(a * c)", i.e. -100,-99,-98, etc but no, at a=-0.91 , I'm getting -0.91*100 = -90 instead of -91. All the rest of the multiplications are fine. Why ??

By the way I'm using the int function because I need to use the variables a and c in a function that only takes integers.

kazordoon
  • 29
  • 4

0 Answers0