Cancellation of inequalities in floating point arithmetic In finite precision floating point arithmetic the associative property of addition is not satisfied. This is, it is not always the case that $$(a+b)+c=a+(b+c)$$
Even $a=(a+b)-b$ is not always true.
To prove that $x+y&lt;z$ is equivalent to $x&lt;z-y$ with real numbers we can add $-y$ on both sides of $x+y&lt;z$ to get $(x+y)-y&lt;z-y$ and then from this $x=x+(y-y)&lt;z-y$. But I can't repeat the last step for floating point.

Question 1: Are the inequalities $x+y&lt;z$ and $x&lt;z-y$ equivalent in finite precision floating point arithmetic?


Question 2: Are the inequalities $x+y\leq z$ and $x\leq z-y$ equivalent in finite precision floating point arithmetic?

I was too hasty and updated without checking properly. What I really indented to ask is if the breaking of the equivalence could be as drastic as:

Question 3: Could we have $x+y&lt;z$ and $x&gt;z-y$?

Possibly there are already answers below for this. If so, I will check them when I get a chance and select the answer.

Motivation: There is that interview problem that given an ordered array of numbers and a threshold it asks for the number of pairs of numbers of the array which sum is not larger than the threshold. Possible solutions aside, I wanted to understand the particular point of the dangers of switching between testing $x+y&lt;z$ (and also $\leq$ depending on which variant of the problem is presented) and testing $x&lt;z-y$ (or $\leq$).
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 negative, and y = z and much larger in magnitude than x. Then x + y = y = z, but z - y = 0, which is larger than x.
The examples work for your second question as well if you flip the signs of all numbers - !(l &gt; r) is nearly equivalent to l &lt;= r. NaNs break the equivalence, but those aren't useful as examples to your question anyways.