fix DECIMAL_DIG definitions
authorRich Felker <dalias@aerifal.cx>
Wed, 21 Mar 2012 16:42:48 +0000 (12:42 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 21 Mar 2012 16:42:48 +0000 (12:42 -0400)
DECIMAL_DIG is not the same as LDBL_DIG

type_DIG is the maximimum number of decimal digits that can survive a
round trip from decimal to type and back to decimal.

DECIMAL_DIG is the minimum number of decimal digits required in order
for any floating point type to survive the round trip to decimal and
back, and it is generally larger than LDBL_DIG. since the exact
formula is non-trivial, and defining it larger than necessary may be
legal but wasteful, just define the right value in bits/float.h.

arch/arm/bits/float.h
arch/i386/bits/float.h
arch/x86_64/bits/float.h
include/float.h

index 75fdc9b..dce9e2d 100644 (file)
@@ -12,3 +12,5 @@
 #define LDBL_DIG 15
 #define LDBL_MIN_10_EXP (-307)
 #define LDBL_MAX_10_EXP 308
 #define LDBL_DIG 15
 #define LDBL_MIN_10_EXP (-307)
 #define LDBL_MAX_10_EXP 308
+
+#define DECIMAL_DIG 17
index 044b516..d439d40 100644 (file)
@@ -12,3 +12,5 @@
 #define LDBL_DIG 18
 #define LDBL_MIN_10_EXP (-4931)
 #define LDBL_MAX_10_EXP 4932
 #define LDBL_DIG 18
 #define LDBL_MIN_10_EXP (-4931)
 #define LDBL_MAX_10_EXP 4932
+
+#define DECIMAL_DIG 21
index a58424e..422a2df 100644 (file)
@@ -12,3 +12,5 @@
 #define LDBL_DIG 18
 #define LDBL_MIN_10_EXP (-4931)
 #define LDBL_MAX_10_EXP 4932
 #define LDBL_DIG 18
 #define LDBL_MIN_10_EXP (-4931)
 #define LDBL_MAX_10_EXP 4932
+
+#define DECIMAL_DIG 21
index ef91f37..ea25f27 100644 (file)
@@ -29,6 +29,4 @@
 
 #include <bits/float.h>
 
 
 #include <bits/float.h>
 
-#define DECIMAL_DIG LDBL_DIG
-
 #endif
 #endif