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]

[patch/rfc] Change floatformat's exp_bias to an int


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.

Index: floatformat.h
===================================================================
RCS file: /cvs/src/src/include/floatformat.h,v
retrieving revision 1.5
diff -u -r1.5 floatformat.h
--- floatformat.h	6 Mar 2002 06:29:41 -0000	1.5
+++ floatformat.h	4 Dec 2002 16:47:54 -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]