qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/5] softfloat: fix float{32, 64}_muladd options


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 1/5] softfloat: fix float{32, 64}_muladd options
Date: Sun, 9 Sep 2012 11:25:22 +0100

On 9 September 2012 10:24, Aurelien Jarno <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]