diff options
author | bde <bde@FreeBSD.org> | 2008-03-05 11:11:53 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2008-03-05 11:11:53 +0000 |
commit | bc7b82cc51924f217b9348af0e207e304684d95c (patch) | |
tree | fc8d1c7dedd53df895270862574c356f262ecc7e | |
parent | 3c423712fa46ed696a32829ee64e71ff46173d00 (diff) | |
download | FreeBSD-src-bc7b82cc51924f217b9348af0e207e304684d95c.zip FreeBSD-src-bc7b82cc51924f217b9348af0e207e304684d95c.tar.gz |
Change float_t and double_t to long double on i386. All floating point
expressions on i386 are evaluated in the range of the long double type,
so this is wrong in a different but hopefully less worse way than
before. Since expressions are evaluated in long double registers,
there is no runtime cost to using long double instead of double to
declare intermediate values (except in cases where this avoids compiler
bugs), and by careful use of float_t or double_t it is possible to
avoid some of the compiler bugs in this area, provided these types are
declared as long double.
I was going to change float.h to be less broken and more usable in
combination with the change here (in particular, it is more necessary
to know the effective number of bits in a double_t when double_t !=
double, since DBL_MANT_DIG no longer logically gives this, and
LDBL_MANT_DIG doesn't give it either with FreeBSD-i386's default
rounding precision. However, this was too hard for now. In particular,
LDBL_MANT_DIG is used a lot in libm, so it cannot be changed. One
thing that is completely broken now is LDBL_MAX. This may have sort
of worked when it was changed from DBL_MAX in 2002 (adding 0 to it at
runtime gave +Inf, but you could at least compare with it), but starting
with gcc-3.3.1 in 2003, it is always +Inf due to evaluating it at
compile time in the default rounding precision.
-rw-r--r-- | sys/i386/include/float.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/i386/include/float.h b/sys/i386/include/float.h index 52b899f..f7f1278 100644 --- a/sys/i386/include/float.h +++ b/sys/i386/include/float.h @@ -66,13 +66,14 @@ __END_DECLS #define DBL_MAX 1.7976931348623157E+308 #define DBL_MAX_10_EXP 308 -#define LDBL_MANT_DIG 64 -#define LDBL_EPSILON 1.0842021724855044340E-19L +#define LDBL_MANT_DIG DBL_MANT_DIG +#define LDBL_EPSILON DBL_EPSILON #define LDBL_DIG 18 #define LDBL_MIN_EXP (-16381) -#define LDBL_MIN 3.3621031431120935063E-4932L +#define LDBL_MIN 3.36210314311209350626E-4932L #define LDBL_MIN_10_EXP (-4931) #define LDBL_MAX_EXP 16384 -#define LDBL_MAX 1.1897314953572317650E+4932L +#define LDBL_MAX 1.18973149535723163300E+4932L #define LDBL_MAX_10_EXP 4932 + #endif /* _MACHINE_FLOAT_H_ */ |