4 ms·
Why do you say that? It extracts the bits using doubleToRawLongBits which does not do NaN canonicalization by design. And it gets back to a double with longBi
by ectopod 5y ago
Why do you say that? It extracts the bits using doubleToRawLongBits which does not do NaN canonicalization by design. And it gets back to a double with longBitsToDouble which "returns the double floating-point value with the same bit pattern". So it doesn't change anything either.
- im3w1l 5y agoNaN values can have sign bit set. This will unset it.
- toxik 5y agoSo we defined abs(NaN), sounds like a feature to me ;-)
- gene91 5y agoYou made a good point. But one might argue that -nan should become nan after an abs operation. I don't know enough about this topic to determine whether such an argument has merit though.
- HWR_14 5y agoIt's not -NaN vs NaN. There are a bunch of NaN types, which are not related like that. It could (according to the spec) change "NaN: Attempt to arcsin value greater than 1" to "NaN: Zero divided by Zero operation"
- im3w1l 5y agoToo late to edit now, but the floating point standard actually specifies that this is what abs should do.
- kennywinker 5y agoThey really missed an opportunity to call it caNaNicalization