On Wed, Jul 9, 2014 at 3:00 AM, Steven D'Aprano <steve at pearwood.info> wrote: > On Tue, Jul 08, 2014 at 04:58:33PM +0200, Anders J. Munch wrote: > >> For two NaNs computed differently to compare equal is no worse than 2+2 >> comparing equal to 1+3. You're comparing values, not their history. > > a = -23 > b = -42 > if log(a) == log(b): > print "a == b" That could also happen from rounding error, though. >>> a = 2.0**52 >>> b = a+1.0 >>> a == b False >>> log(a) == log(b) True Any time you do any operation on numbers that are close together but not equal, you run the risk of getting results that, in finite-precision floating point, are deemed equal, even though mathematically they shouldn't be (two unequal numbers MUST have unequal logarithms). ChrisA
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4