3 ms·
IEEE 754 requires that -0.0 and 0.0 compare equal. > Does x*0 evaluate to 0.0 No, but it will compare equal, unless x is either infinite or a NaN. > Does x+0
by wnoise 6y ago
IEEE 754 requires that -0.0 and 0.0 compare equal.
> Does x*0 evaluate to 0.0
No, but it will compare equal, unless x is either infinite or a NaN.
> Does x+0 evaluate to x? Maybe!
Yes, unless x is either infinite or a NaN.
- bjourne 6y agoNo, if x = -0.0 then x+0 = 0.0 and x*0 = -0.0. This violates fundamental tenets of arithmetic, surprises most, and makes many compiler optimizations impossible.