Document: WG14 N1469
Submitter: Fred J. Tydeman (USA)
Submission Date: 2010-05-10
Related documents: N1399
Subject: F.9.2: x-y <--> x+(-y)
Background: As I discovered when I wrote my complex multiply and complex divide implementations (N1399), x-y and x+(-y) are not equivalent when y is a NaN. Most machines pass a NaN unchanged thru a subtract or an add, but a negate flips the sign bit of the NaN. So, the result of the two different expressions is the same NaN, except for the sign bit.
Also, if both x and y are different NaNs, some machines use the left operand as the result of a binary operation. Hence, x+(-y), and (-y)+x will produce different results.
F.9.2 Expression transformations has:
x-y <--> x+(-y)
The expressions x-y, x+(-y), and (-y)+x are equivalent (on IEC 60559 machines, amoung others).
That should be changed to:
x-y <--> x+(-y)
The expressions x-y, x+(-y), and (-y)+x are equivalent as long as y is not a NaN (on IEC 60559 machines, amoung others).