int((9.2-9.0)*10) is 1, int((9.21-9.0)*10) is 2, why?

B

bcm

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
The following line of code describes an funny question$B!'(B2

why? anybody can explain it?
 
J

John Machin

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
The following line of code describes an funny question$B!'(B>>> int((9.2-9.0)*10)
1
2

why? anybody can explain it?


Try looking one step at a time:9.1999999999999993

That wasn't hard, was it? Do you need any further explanation? If so,
look here:
http://docs.python.org/tut/node16.html
 
B

bcm

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
The following line of code describes an funny question$B!'(B>>> int((9.2-9.0)*10)
1
int((9.21-9.0)*10) 2
0
1
1

why? anybody can explain it?

Try looking one step at a time:>>> 9.2

9.1999999999999993

That wasn't hard, was it? Do you need any further explanation? If so,
look here:http://docs.python.org/tut/node16.html

thanks a lot, i am really really stupid ~*v*~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,164
Latest member
quinoxflush
Top