mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
math: Fix exp10 undefined left shift
Left shift of ki is undefined when ki<0, copy the logic from exp, which uses unsigned arithmetics, to fix it. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
d0106b6ae2
commit
2a9943b4a0
1 changed files with 3 additions and 3 deletions
|
@ -38,7 +38,7 @@ special_case (uint64_t sbits, double_t tmp, uint64_t ki)
|
||||||
{
|
{
|
||||||
double_t scale, y;
|
double_t scale, y;
|
||||||
|
|
||||||
if (ki - (1ull << 16) < 0x80000000)
|
if ((ki & 0x80000000) == 0)
|
||||||
{
|
{
|
||||||
/* The exponent of scale might have overflowed by 1. */
|
/* The exponent of scale might have overflowed by 1. */
|
||||||
sbits -= 1ull << 52;
|
sbits -= 1ull << 52;
|
||||||
|
@ -100,14 +100,14 @@ __exp10 (double x)
|
||||||
/* Reduce x: z = x * N / log10(2), k = round(z). */
|
/* Reduce x: z = x * N / log10(2), k = round(z). */
|
||||||
double_t z = __exp_data.invlog10_2N * x;
|
double_t z = __exp_data.invlog10_2N * x;
|
||||||
double_t kd;
|
double_t kd;
|
||||||
int64_t ki;
|
uint64_t ki;
|
||||||
#if TOINT_INTRINSICS
|
#if TOINT_INTRINSICS
|
||||||
kd = roundtoint (z);
|
kd = roundtoint (z);
|
||||||
ki = converttoint (z);
|
ki = converttoint (z);
|
||||||
#else
|
#else
|
||||||
kd = math_narrow_eval (z + Shift);
|
kd = math_narrow_eval (z + Shift);
|
||||||
|
ki = asuint64 (kd);
|
||||||
kd -= Shift;
|
kd -= Shift;
|
||||||
ki = kd;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* r = x - k * log10(2), r in [-0.5, 0.5]. */
|
/* r = x - k * log10(2), r in [-0.5, 0.5]. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue