Message175495
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) |
|
Date |
User |
Action |
Args |
2012-11-13 10:18:49 | loewis | set | recipients:
+ loewis, mark.dickinson, skrah, serhiy.storchaka, tom.pohl |
2012-11-13 10:18:49 | loewis | link | issue16460 messages |
2012-11-13 10:18:48 | loewis | create | |
|