* floatformat.c (floatformat_to_double): Correctly handle numbers
between 1 and 2. Simplify handling of denormal number. (main): Test with 1.1.
This commit is contained in:
parent
db7618108f
commit
e372c21ce5
2 changed files with 20 additions and 24 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2012-08-17 Andreas Schwab <schwab@linux-m68k.org>
|
||||||
|
|
||||||
|
* floatformat.c (floatformat_to_double): Correctly handle numbers
|
||||||
|
between 1 and 2. Simplify handling of denormal number.
|
||||||
|
(main): Test with 1.1.
|
||||||
|
|
||||||
2012-07-31 Mike Frysinger <vapier@gentoo.org>
|
2012-07-31 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
* md5.c (md5_finish_ctx): Declare swap_bytes. Assign SWAP() output
|
* md5.c (md5_finish_ctx): Declare swap_bytes. Assign SWAP() output
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* IEEE floating point support routines, for GDB, the GNU Debugger.
|
/* IEEE floating point support routines, for GDB, the GNU Debugger.
|
||||||
Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006, 2010
|
Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006, 2010, 2012
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GDB.
|
This file is part of GDB.
|
||||||
|
@ -463,7 +463,6 @@ floatformat_to_double (const struct floatformat *fmt,
|
||||||
unsigned long mant;
|
unsigned long mant;
|
||||||
unsigned int mant_bits, mant_off;
|
unsigned int mant_bits, mant_off;
|
||||||
int mant_bits_left;
|
int mant_bits_left;
|
||||||
int special_exponent; /* It's a NaN, denorm or zero */
|
|
||||||
|
|
||||||
/* Split values are not handled specially, since the top half has
|
/* Split values are not handled specially, since the top half has
|
||||||
the correctly rounded double value (in the only supported case of
|
the correctly rounded double value (in the only supported case of
|
||||||
|
@ -503,20 +502,20 @@ floatformat_to_double (const struct floatformat *fmt,
|
||||||
mant_off = fmt->man_start;
|
mant_off = fmt->man_start;
|
||||||
dto = 0.0;
|
dto = 0.0;
|
||||||
|
|
||||||
special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan;
|
|
||||||
|
|
||||||
/* Don't bias zero's, denorms or NaNs. */
|
|
||||||
if (!special_exponent)
|
|
||||||
exponent -= fmt->exp_bias;
|
|
||||||
|
|
||||||
/* Build the result algebraically. Might go infinite, underflow, etc;
|
/* Build the result algebraically. Might go infinite, underflow, etc;
|
||||||
who cares. */
|
who cares. */
|
||||||
|
|
||||||
/* If this format uses a hidden bit, explicitly add it in now. Otherwise,
|
/* For denorms use minimum exponent. */
|
||||||
increment the exponent by one to account for the integer bit. */
|
if (exponent == 0)
|
||||||
|
exponent = 1 - fmt->exp_bias;
|
||||||
if (!special_exponent)
|
else
|
||||||
{
|
{
|
||||||
|
exponent -= fmt->exp_bias;
|
||||||
|
|
||||||
|
/* If this format uses a hidden bit, explicitly add it in now.
|
||||||
|
Otherwise, increment the exponent by one to account for the
|
||||||
|
integer bit. */
|
||||||
|
|
||||||
if (fmt->intbit == floatformat_intbit_no)
|
if (fmt->intbit == floatformat_intbit_no)
|
||||||
dto = ldexp (1.0, exponent);
|
dto = ldexp (1.0, exponent);
|
||||||
else
|
else
|
||||||
|
@ -530,18 +529,8 @@ floatformat_to_double (const struct floatformat *fmt,
|
||||||
mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
|
mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
|
||||||
mant_off, mant_bits);
|
mant_off, mant_bits);
|
||||||
|
|
||||||
/* Handle denormalized numbers. FIXME: What should we do for
|
dto += ldexp ((double) mant, exponent - mant_bits);
|
||||||
non-IEEE formats? */
|
exponent -= mant_bits;
|
||||||
if (special_exponent && exponent == 0 && mant != 0)
|
|
||||||
dto += ldexp ((double)mant,
|
|
||||||
(- fmt->exp_bias
|
|
||||||
- mant_bits
|
|
||||||
- (mant_off - fmt->man_start)
|
|
||||||
+ 1));
|
|
||||||
else
|
|
||||||
dto += ldexp ((double)mant, exponent - mant_bits);
|
|
||||||
if (exponent != 0)
|
|
||||||
exponent -= mant_bits;
|
|
||||||
mant_off += mant_bits;
|
mant_off += mant_bits;
|
||||||
mant_bits_left -= mant_bits;
|
mant_bits_left -= mant_bits;
|
||||||
}
|
}
|
||||||
|
@ -756,6 +745,7 @@ main (void)
|
||||||
{
|
{
|
||||||
ieee_test (0.0);
|
ieee_test (0.0);
|
||||||
ieee_test (0.5);
|
ieee_test (0.5);
|
||||||
|
ieee_test (1.1);
|
||||||
ieee_test (256.0);
|
ieee_test (256.0);
|
||||||
ieee_test (0.12345);
|
ieee_test (0.12345);
|
||||||
ieee_test (234235.78907234);
|
ieee_test (234235.78907234);
|
||||||
|
|
Loading…
Reference in a new issue