How can I determine the sign of the result of an addition in floating-point arithmetic?
I'm not sure if I've seen any info about it in standard IEEE-754, but my guess is: implement addition and subtraction of non-negative numbers and then change sign of result according to needs. Is it right?
If the mathematical sum of two numbers is non-zero, the floating-point result has the same sign as the mathematical sum, even if the floating-point result is zero. The latter is due to IEEE 754-2019 4.3, first paragraph: “Inexact numeric floating-point results always have the same sign as the unrounded result.”
If the mathematical sum is zero, then, per IEEE 754-2019 6.3, third paragraph: