qemu-stable
[Top][All Lists]
Advanced

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

Re: [PATCH] softfloat: Fix the incorrect computation in float32_exp2()


From: Michael Tokarev
Subject: Re: [PATCH] softfloat: Fix the incorrect computation in float32_exp2()
Date: Thu, 4 May 2023 16:32:03 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0

02.05.2023 18:25, Shivaprasad G Bhat wrote:
The float32_exp2() is computing wrong exponent of 2.
For example, with the following set of values {0.1, 2.0, 2.0, -1.0},
the expected output would be {1.071773, 4.000000, 4.000000, 0.500000}.
Instead, the function is computing {1.119102, 3.382044, 3.382044, -0.191022}

Looking at the code, the float32_exp2() attempts to do this

                   2     3     4     5           n
   x        x     x     x     x     x           x
  e  = 1 + --- + --- + --- + --- + --- + ... + --- + ...
            1!    2!    3!    4!    5!          n!

But because of the 'typo'/bug it ends up doing

  x        x     x     x     x     x           x
e  = 1 + --- + --- + --- + --- + --- + ... + --- + ...
           1!    2!    3!    4!    5!          n!

This is because instead of the xnp which holds the numerator,
parts_muladd is using the xp which is just 'x'. The commit '572c4d862ff2'
refactored this function, and it seems mistakenly using xp instead of xnp.

The patches fixes this possible typo.

This smells like a -stable material.

/mjt



reply via email to

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