"Jonathan M Davis" <jmdavisp...@gmx.com> writes: > On Monday, 22 June 2015 at 08:10:20 UTC, Dan Olson wrote: >> Docs for isIdentical say: >> >> Same as ==, except that positive and negative zero are not >> identical, >> and two NANs are identical if they have the same 'payload'. >> >> However, it returns false for NaN's with different signbits but same >> payload. Should this be the case? >> >> Ran into this because isIdentical is used in unittests to compare >> NaN's but I find an occassional test fails due to signbit for some >> operations on LDC ARM. I wrote an isNaNWithPayload() predicate for >> the failing tests, but wonder if isIdentical should ignore signbit >> for NaNs or have its docs changed. > > Well, given the name of the function and the fact that it's clearly > trying to check for NaN equality rather than treating their comparison > as always false, I would have expected that it would be true for NaNs > if they were absolutely identical, which presumably includes the > signbit, but I really don't know much about how NaNs are implemented, > so I don't know what the implications of that are. Still, it seems odd > to compare part of the NaN for equality but not all of it.
Yeah, based on the name "isIdentical", its current behaviour assert(!isIdentical(-NaN(0xabc), NaN(0xabc)); does seem to correct. In that case the documentation could say "NaNs are identical if they have the same payload and signbit".