This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author loewis
Recipients loewis, mark.dickinson, serhiy.storchaka, skrah, tom.pohl
Date 2012-11-13.10:18:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <50A21E8D.3080608@v.loewis.de>
In-reply-to <1352728421.95.0.44557665826.issue16460@psf.upfronthosting.co.za>
Content
Am 12.11.12 14:53, schrieb Tom Pohl:
> What do I expect from FD (x//y):
> 1. Perform a division (I don't care about the details here).
> 2. Return an integer value q (even if it's stored in a float).
> 3. The absolute difference between the mathematical division q'=x/y and the returned result q is less than 1, since it's just a floor operation, right?
>
> 1//0.1 = 9.0 violates my personal last expectation and I guess I'm not the only one.

However, it matches *precisely* your description of what you expect:

1. 1 divided-by 0.1 gives
9.99999999999999944488848768742176060306327615036178207623262235371852234374499248...

Please understand that the correct result of 1 divided-by 0.1 is *not* 
10, because 0.1 is *not* 1/10.

2. returned is then the integer 9

3. the difference is
.99999999999999944488848768742176060306327615036178207623262235371852234374499248...
which is indeed smaller than 1.

P.S. In case you want to get a more exact result of 1 divided-by 0.1, 
get the digits from

int(1/fractions.Fraction(0.1)*10**180)
History
Date User Action Args
2012-11-13 10:18:49loewissetrecipients: + loewis, mark.dickinson, skrah, serhiy.storchaka, tom.pohl
2012-11-13 10:18:49loewislinkissue16460 messages
2012-11-13 10:18:48loewiscreate