It's perhaps worth noting that, with floats, if $x == $y it does not necessarily follow that $x - $y == 0, or that abs($x - $y) <= 1 If $x and $y are both infinities (of the same sign) then the first condition holds true, while the second and third are false.