3 ms·
More information isn't better if that information isn't useful. Does x*0 evaluate to 0.0? Not with -0 around. Does x+0 evaluate to x? Maybe!
by bjourne 6y ago
More information isn't better if that information isn't useful. Does x*0 evaluate to 0.0? Not with -0 around. Does x+0 evaluate to x? Maybe!
- wnoise 6y agoIEEE 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.