2013-05-06 Thomas Schwinge <thomas@codesourcery.com>
+ * fp-bit.c (unpack_d, pack_d): Properly preserve and restore a
+ NaN's payload.
+
* fp-bit.h [FLOAT] (QUIET_NAN): Correct value.
2013-04-25 Alan Modra <amodra@gmail.com>
else if (isnan (src))
{
exp = EXPMAX;
+ /* Restore the NaN's payload. */
+ fraction >>= NGARDS;
+ fraction &= QUIET_NAN - 1;
if (src->class == CLASS_QNAN || 1)
{
#ifdef QUIET_NAN_NEGATED
- fraction |= QUIET_NAN - 1;
+ /* The quiet/signaling bit remains unset. */
+ /* Make sure the fraction has a non-zero value. */
+ if (fraction == 0)
+ fraction |= QUIET_NAN - 1;
#else
+ /* Set the quiet/signaling bit. */
fraction |= QUIET_NAN;
#endif
}
{
dst->class = CLASS_SNAN;
}
- /* Keep the fraction part as the nan number */
- dst->fraction.ll = fraction;
+ /* Now that we know which kind of NaN we got, discard the
+ quiet/signaling bit, but do preserve the NaN payload. */
+ fraction &= ~QUIET_NAN;
+ dst->fraction.ll = fraction << NGARDS;
}
}
else
/* numeric parameters */
/* F_D_BITOFF is the number of bits offset between the MSB of the mantissa
of a float and of a double. Assumes there are only two float types.
- (double::FRAC_BITS+double::NGARDS-(float::FRAC_BITS-float::NGARDS))
+ (double::FRAC_BITS+double::NGARDS-(float::FRAC_BITS+float::NGARDS))
*/
#define F_D_BITOFF (52+8-(23+7))