79382686

Date: 2025-01-23 22:03:25
Score: 0.5
Natty:
Report link

IEEE754 says that the result is as if computed exactly and then rounded.

mathematically x-x=0 for real x exactly. Since 0 is exactly representable, this shall be the result in IEEE754 arithmetic.

On the other hand, there are two numbers with value 0, namely +0 and -0.

The standard says:

When the sum of two operands with opposite signs (or the difference of two operands with like signs) is exactly zero, the sign of that sum (or difference) shall be +0 in all rounding-direction attributes except roundTowardNegative; under that attribute, the sign of an exact zero sum (or difference) shall be −0.

So, x-x may be +0 or -0 and what it is depends on the rounding mode.

If x is an infinite value, the result is nan. If x is itself nan, then the result is nan as well.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: user2609605