This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Make exp_bias an int


FYI,

I've committed the attached.  It was originally posted:
http://sources.redhat.com/ml/gdb-patches/2002-12/msg00115.html
Hello,

The attached addresses a problem with float format's exp_bias (the _difference_ between a true and biased exponent). It was an unsigned, instead of an int. Unfortunatly, due to the nature of C's conversion rules, that unsigned can result in strange behavior. As the comment notes:

+ /* Bias added to a "true" exponent to form the biased exponent. It
+ is intentionally signed as, otherwize, -exp_bias can turn into a
+ very large number (e.g., given the exp_bias of 0x3fff and a 64
+ bit long, the equation (long)(1 - exp_bias) evaluates to
+ 4294950914) instead of -16382). */

Baring comment, I'll [double] commit this in a few days.

Andrew

Wed Dec 4 11:36:04 2002 Andrew Cagney <cagney@redhat.com>

* floatformat.h (struct floatformat): Change exp_bias to an int.

I guess people have had a bit more than a couple of days :-)

Andrew
2003-09-15  Andrew Cagney  <cagney@redhat.com>

	* floatformat.h (struct floatformat): Make "exp_bias" signed.

Index: floatformat.h
===================================================================
RCS file: /cvs/gcc/gcc/include/floatformat.h,v
retrieving revision 1.7
diff -u -r1.7 floatformat.h
--- floatformat.h	15 Sep 2003 20:16:22 -0000	1.7
+++ floatformat.h	15 Sep 2003 21:16:28 -0000
@@ -61,8 +61,12 @@
 
   unsigned int exp_start;
   unsigned int exp_len;
-  /* Amount added to "true" exponent.  0x3fff for many IEEE extendeds.  */
-  unsigned int exp_bias;
+  /* Bias added to a "true" exponent to form the biased exponent.  It
+     is intentionally signed as, otherwize, -exp_bias can turn into a
+     very large number (e.g., given the exp_bias of 0x3fff and a 64
+     bit long, the equation (long)(1 - exp_bias) evaluates to
+     4294950914) instead of -16382).  */
+  int exp_bias;
   /* Exponent value which indicates NaN.  This is the actual value stored in
      the float, not adjusted by the exp_bias.  This usually consists of all
      one bits.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]