f



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

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・3校
>>> int((9.2-9.0)*10)
1
>>> int((9.21-9.0)*10)
2
>>> int((9.1-9.0)*10)
0
>>> int((9.11-9.0)*10)
1
>>> int((8.2-8.0)*10)
1
>>> int((8.23-8.0)*10)
2

why? anybody can explain it?
0
9/5/2008 1:12:41 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

2 Replies
1194 Views

Similar Articles

[PageSpeed] 17

On Sep 5, 11:12 pm, bcm <bluecrysta...@gmail.com> wrote:
> 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・3校>>> int((9.2-9.0)*10)
> 1
> >>> int((9.21-9.0)*10)
> 2
> >>> int((9.1-9.0)*10)
> 0
> >>> int((9.11-9.0)*10)
> 1
> >>> int((8.2-8.0)*10)
> 1
> >>> int((8.23-8.0)*10)
>
> 2
>
> 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


0
sjmachin (3097)
9/5/2008 1:29:54 PM
On Sep 5, 9:29 pm, John Machin <sjmac...@lexicon.net> wrote:
> On Sep 5, 11:12 pm, bcm <bluecrysta...@gmail.com> wrote:
>
>
>
> > 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・3校>>> int((9.2-9.0)*10)
> > 1
> > >>> int((9.21-9.0)*10)
> > 2
> > >>> int((9.1-9.0)*10)
> > 0
> > >>> int((9.11-9.0)*10)
> > 1
> > >>> int((8.2-8.0)*10)
> > 1
> > >>> int((8.23-8.0)*10)
>
> > 2
>
> > 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*~
0
9/5/2008 1:44:13 PM
Reply: