On 9 September 2012 10:24, Aurelien Jarno <aurel...@aurel32.net> wrote:
> My idea was that negating both the product and c is equivalent to
> negating the result, so there is no need to allow all of them
> independent.

This is the kind of statement about floating point arithmetic that
sounds plausible but turns out to be untrue for some odd corner
case. Consider a = +0, b = +0, c = -0.

If we're negating the result, then:
 -((a * b) + c) = -((+0 * +0) + -0)
                = -(+0 + -0)
                = -(+0)
                = -0

(assuming round to nearest; rounding mode affects the answer
to '+0 + -0')

If we negate both product and c:
 (-(a * b) + -c) = (-(+0 * +0) + -(-0))
                 = (-(+0) + +0)
                 = (-0 + +0)
                 = +0

so the two calculations give us zeros of different sign.

-- PMM

Reply via email to