From: | Michael Orlitzky <mjo@g.o> | ||
---|---|---|---|
To: | gentoo-user@l.g.o | ||
Subject: | Re: [gentoo-user] 69.99 != 69.99 | ||
Date: | Sat, 22 Aug 2015 18:04:29 | ||
Message-Id: | 55D8B9A1.90407@gentoo.org | ||
In Reply to: | Re: [gentoo-user] 69.99 != 69.99 by allan gottlieb |
1 | On 08/22/2015 01:27 PM, allan gottlieb wrote: |
2 | >> |
3 | >> Floating point addition isn't even commutative: |
4 | >> |
5 | >> > 0.1 + 0.2 + 0.3 |
6 | >> 0.6000000000000001 |
7 | >> > 0.1 + (0.2 + 0.3) |
8 | >> 0.6 |
9 | > |
10 | > That demonstrates non-associativity. I believe floating point is |
11 | > commutative: a+b = b+a |
12 | > |
13 | |
14 | Derp, thanks, you're right =) |
15 | |
16 | ...but it's not commutative either: |
17 | |
18 | >>> nan = float('nan') |
19 | >>> nan + 1 == 1 + nan |
20 | False |
21 | |
22 | I'm cheating a bit there, the real problem is: |
23 | |
24 | >>> nan == nan |
25 | False |