There exists a representation of a negative double whose negation is also negative, i.e. a < 0 && -a < 0 holds true? I'm completely out of my depth.
-
-
-
No. That's only possible with twos-complement integers. But you are very close.
- Show replies
New conversation -
-
-
Does it treat NaNs incorrectly in some way? Alternately, might it return -0 sometimes?
-
Only one of those two things is true. ;)
End of conversation
New conversation -
-
-
With -NaN as input, your function returns -NaN instead of +NaN.
-
On some implementations yes, but I _think_ that's within allowed behavior for fabs(), so it's technically not incorrect.
End of conversation
New conversation -
-
-
fmax on zeros is required to return one of them but it is implementation defined which so fabs(0) = fmax(+0, -0) = -0 is possible and that is not fabs!
-
Seven and one third internet points for you! :D
- Show replies
New conversation -
-
-
I don't see the problem with this one. Either the compiler doesn't promise IEEE 754 and -x doesn't even need to be exact, or it does but (see other discussion) the sign bit of NaN is meaningless (and even getting the correct payload is a stretch tbh). Is this about 0. and -0.?
-
Yes, it's about negative zero. fmax(+0.0, -0.0) is allowed to return -0.0, and fabs(-0.0) is required to return +0.0.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.