/* IEEE floating point support routines, for GDB, the GNU Debugger.
- Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006
- Free Software Foundation, Inc.
+ Copyright (C) 1991-2019 Free Software Foundation, Inc.
This file is part of GDB.
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
/* This is needed to pick up the NAN macro on some systems. */
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
}
}
-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
+};
\f
#ifndef min
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
int nan = mant_bits_set (fmt, ufrom);
/* On certain systems (such as GNU/Linux), the use of the
- INFINITY macro below may generate a warning that can not be
+ INFINITY macro below may generate a warning that cannot be
silenced due to a bug in GCC (PR preprocessor/11931). The
preprocessor fails to recognise the __extension__ keyword in
conjunction with the GNU/C99 extension for hexadecimal
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
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;
}
{
ieee_test (0.0);
ieee_test (0.5);
+ ieee_test (1.1);
ieee_test (256.0);
ieee_test (0.12345);
ieee_test (234235.78907234);