Skip to content

Commit

Permalink
(__mpn_extract_long_double): Handle 80-bit denormalized numbers correct.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Mar 17, 1995
1 parent c45e5aa commit 61cd951
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sysdeps/ieee754/ldbl2mpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
/* It is a denormal number, meaning it has no implicit leading
one bit, and its exponent is in fact the format minimum. */
int cnt;

/* One problem with Intel's 80-bit format is that the explicit
leading one in the normalized representation has to be zero
for denormalized number. If it is one, the number is according
to Intel's specification an invalid number. We make the
representation unique by explicitly clearing this bit. */
res_ptr[N - 1] &= ~(1 << ((LDBL_MANT_DIG - 1) % BITS_PER_MP_LIMB));

if (res_ptr[N - 1] != 0)
{
count_leading_zeros (cnt, res_ptr[N - 1]);
Expand All @@ -77,14 +85,14 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
res_ptr[N - 1] <<= cnt;
#endif
}
*expt = LDBL_MIN_EXP - 2 - cnt;
*expt = LDBL_MIN_EXP - 1 - cnt;
}
else
{
count_leading_zeros (cnt, res_ptr[0]);
res_ptr[N - 1] = res_ptr[0] << cnt;
res_ptr[0] = 0;
*expt = LDBL_MIN_EXP - 2 - BITS_PER_MP_LIMB - cnt;
*expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt;
}
}
}
Expand Down

0 comments on commit 61cd951

Please sign in to comment.