Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: libiberty/floatformat.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libiberty/cp-demangle.c ('k') | libiberty/functions.texi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libiberty/floatformat.c
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
index 1116c63117dcaa9447622f1e68649df1b48130bb..789fa05777dd3dc36b799e17cad1b91a228062ef 100644
--- a/libiberty/floatformat.c
+++ b/libiberty/floatformat.c
@@ -1,5 +1,5 @@
/* 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.
This file is part of GDB.
@@ -371,14 +371,23 @@ floatformat_ibm_long_double_is_valid (const struct floatformat *fmt,
}
}
-const struct floatformat floatformat_ibm_long_double =
+const struct floatformat floatformat_ibm_long_double_big =
{
floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52,
floatformat_intbit_no,
- "floatformat_ibm_long_double",
+ "floatformat_ibm_long_double_big",
floatformat_ibm_long_double_is_valid,
&floatformat_ieee_double_big
};
+
+const struct floatformat floatformat_ibm_long_double_little =
+{
+ floatformat_little, 128, 0, 1, 11, 1023, 2047, 12, 52,
+ floatformat_intbit_no,
+ "floatformat_ibm_long_double_little",
+ floatformat_ibm_long_double_is_valid,
+ &floatformat_ieee_double_little
+};
#ifndef min
@@ -463,7 +472,6 @@ floatformat_to_double (const struct floatformat *fmt,
unsigned long mant;
unsigned int mant_bits, mant_off;
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
the correctly rounded double value (in the only supported case of
@@ -503,20 +511,20 @@ floatformat_to_double (const struct floatformat *fmt,
mant_off = fmt->man_start;
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;
who cares. */
- /* 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 (!special_exponent)
+ /* For denorms use minimum exponent. */
+ if (exponent == 0)
+ exponent = 1 - fmt->exp_bias;
+ 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)
dto = ldexp (1.0, exponent);
else
@@ -530,18 +538,8 @@ floatformat_to_double (const struct floatformat *fmt,
mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
mant_off, mant_bits);
- /* Handle denormalized numbers. FIXME: What should we do for
- non-IEEE formats? */
- 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;
+ dto += ldexp ((double) mant, exponent - mant_bits);
+ exponent -= mant_bits;
mant_off += mant_bits;
mant_bits_left -= mant_bits;
}
@@ -756,6 +754,7 @@ main (void)
{
ieee_test (0.0);
ieee_test (0.5);
+ ieee_test (1.1);
ieee_test (256.0);
ieee_test (0.12345);
ieee_test (234235.78907234);
« no previous file with comments | « libiberty/cp-demangle.c ('k') | libiberty/functions.texi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698