New answers tagged

1

Take x=1+u, y=1+2u, z=2+4u, where u is the value of the lowest mantissa bit. x+y = 2+3u gets rounded up to 2+4u, so x+y<z is false. z-y = 2+4u - (1+2u) = 1+2u, so x < z-y is true. That’s a counter example for the first case. With x=1+3u you get a counter example for the second case.


1

Consider the case that x and y hold the largest representable value for the current type, and z is positive infinity. By the rules of floating point arithmetics, x + y is now infinity, which isn't less than infinity. On the other hand, z - y is also infinity, which the largest representable value is less than. Another example would be when x is very small ...


Top 50 recent answers are included