From e542c7dedc6a3b2524432a8071672775f96d2a5e Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Thu, 6 Apr 2000 16:45:03 +0000 Subject: [PATCH] ICU-346 change IEEE_754 to a numeric macro (value 0 or 1) X-SVN-Rev: 1080 --- icu4c/source/common/putil.c | 24 ++++++++++++------------ icu4c/source/common/unicode/putil.h | 7 +++++-- icu4c/source/config/mh-os390 | 4 ++-- icu4c/source/test/intltest/nmfmtrt.cpp | 10 +++++----- icu4c/source/test/intltest/numrgts.cpp | 2 +- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/icu4c/source/common/putil.c b/icu4c/source/common/putil.c index b151a53ade5..9d37dd3c1a3 100644 --- a/icu4c/source/common/putil.c +++ b/icu4c/source/common/putil.c @@ -78,7 +78,7 @@ /* floating point implementations ------------------------------------------- */ /* We return QNAN rather than SNAN*/ -#ifdef IEEE_754 +#if IEEE_754 #define NAN_TOP ((int16_t)0x7FF8) #define INF_TOP ((int16_t)0x7FF0) #else @@ -163,7 +163,7 @@ uprv_getUTCtime() bool_t uprv_isNaN(double number) { -#ifdef IEEE_754 +#if IEEE_754 /* This should work in theory, but it doesn't, so we resort to the more*/ /* complicated method below.*/ /* return number != number;*/ @@ -206,7 +206,7 @@ uprv_isNaN(double number) bool_t uprv_isInfinite(double number) { -#ifdef IEEE_754 +#if IEEE_754 /* We know the top bit is the sign bit, so we mask that off in a copy of */ /* the number and compare against infinity. [LIU]*/ /* The following approach doesn't work for some reason, so we go ahead and */ @@ -244,7 +244,7 @@ return ((highBits & ~SIGN) == 0x70FF0000L) && (lowBits == 0x00000000L); bool_t uprv_isPositiveInfinity(double number) { -#if defined(IEEE_754) || defined(OS390) +#if IEEE_754 || defined(OS390) return (number > 0 && uprv_isInfinite(number)); #else return uprv_isInfinite(number); @@ -254,7 +254,7 @@ uprv_isPositiveInfinity(double number) bool_t uprv_isNegativeInfinity(double number) { -#if defined(IEEE_754) || defined(OS390) +#if IEEE_754 || defined(OS390) return (number < 0 && uprv_isInfinite(number)); #else uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, @@ -267,7 +267,7 @@ uprv_isNegativeInfinity(double number) double uprv_getNaN() { -#if defined(IEEE_754) || defined(OS390) +#if IEEE_754 || defined(OS390) if( ! fgNaNInitialized) { umtx_lock(NULL); if( ! fgNaNInitialized) { @@ -292,7 +292,7 @@ uprv_getNaN() double uprv_getInfinity() { -#if defined(IEEE_754 ) || defined(OS390) +#if IEEE_754 || defined(OS390) if (!fgInfInitialized) { int i; @@ -379,7 +379,7 @@ uprv_pow10(int32_t x) double uprv_IEEEremainder(double x, double p) { -#ifdef IEEE_754 +#if IEEE_754 int32_t hx, hp; uint32_t sx, lx, lp; double p_half; @@ -458,7 +458,7 @@ uprv_IEEEremainder(double x, double p) double uprv_fmax(double x, double y) { -#ifdef IEEE_754 +#if IEEE_754 int32_t lowBits; /* first handle NaN*/ @@ -491,7 +491,7 @@ uprv_max(int32_t x, int32_t y) double uprv_fmin(double x, double y) { -#ifdef IEEE_754 +#if IEEE_754 int32_t lowBits; /* first handle NaN*/ @@ -532,7 +532,7 @@ uprv_min(int32_t x, int32_t y) double uprv_trunc(double d) { -#ifdef IEEE_754 +#if IEEE_754 int32_t lowBits; @@ -1298,7 +1298,7 @@ uprv_getDefaultLocaleID() double uprv_nextDouble(double d, bool_t next) { -#ifdef IEEE_754 +#if IEEE_754 int32_t highBits; uint32_t lowBits; int32_t highMagnitude; diff --git a/icu4c/source/common/unicode/putil.h b/icu4c/source/common/unicode/putil.h index 470c3d93cbc..c4c097613f3 100644 --- a/icu4c/source/common/unicode/putil.h +++ b/icu4c/source/common/unicode/putil.h @@ -26,8 +26,11 @@ #include "unicode/utypes.h" -/* Define this if your platform supports IEEE 754 floating point */ -#define IEEE_754 +/* Define this to 1 if your platform supports IEEE 754 floating point, + to 0 if it does not. */ +#ifndef IEEE_754 +# define IEEE_754 1 +#endif /*===========================================================================*/ /* Platform utilities */ diff --git a/icu4c/source/config/mh-os390 b/icu4c/source/config/mh-os390 index ccc89966745..f3d54251227 100644 --- a/icu4c/source/config/mh-os390 +++ b/icu4c/source/config/mh-os390 @@ -21,9 +21,9 @@ ################################################################### ifeq (${IEEE390}, 1) -ICU_IEEE = -Wc,"float(ieee)" -DIEEE_ON +ICU_IEEE = -Wc,"float(ieee)" -DIEEE_754=1 else -ICU_IEEE = +ICU_IEEE = -DIEEE_754=0 endif CFLAGS390= -Wc,"langlvl(extended),spill(2000)" $(ICU_BUILD_OPTIONS) $(ICU_IEEE) -Wc,dll,expo diff --git a/icu4c/source/test/intltest/nmfmtrt.cpp b/icu4c/source/test/intltest/nmfmtrt.cpp index 35a90382c82..e0e0ddc42b7 100644 --- a/icu4c/source/test/intltest/nmfmtrt.cpp +++ b/icu4c/source/test/intltest/nmfmtrt.cpp @@ -110,7 +110,7 @@ NumberFormatRoundTripTest::test(NumberFormat *fmt) { if (TRUE) { -#if !defined(OS390) || defined(IEEE_ON) +#if IEEE_754 test(fmt, uprv_getNaN()); test(fmt, uprv_getInfinity()); test(fmt, -uprv_getInfinity()); @@ -133,7 +133,7 @@ NumberFormatRoundTripTest::test(NumberFormat *fmt) test(fmt, randomDouble(1e-50)); #ifndef OS390 test(fmt, randomDouble(1e100)); -#elif defined(IEEE_ON) +#elif IEEE_754 test(fmt, randomDouble(1e75)); /*OS390*/ #endif // {sfb} When formatting with a percent instance, numbers very close to @@ -150,7 +150,7 @@ NumberFormatRoundTripTest::test(NumberFormat *fmt) #ifndef OS390 test(fmt, randomDouble(1e308) / ((DecimalFormat*)fmt)->getMultiplier()); #else -# ifdef IEEE_ON +# if IEEE_754 test(fmt, randomDouble(1e75) / ((DecimalFormat*)fmt)->getMultiplier()); # else test(fmt, randomDouble(1e65) / ((DecimalFormat*)fmt)->getMultiplier()); /*OS390*/ @@ -162,7 +162,7 @@ NumberFormatRoundTripTest::test(NumberFormat *fmt) // doesn't match NT test(fmt, randomDouble(1e-290)); #elif defined(OS390) -# ifdef IEEE_ON +# if IEEE_754 test(fmt, randomDouble(1e-78)); /*OS390*/ # endif #else @@ -170,7 +170,7 @@ NumberFormatRoundTripTest::test(NumberFormat *fmt) #endif #ifndef OS390 test(fmt, randomDouble(1e-100)); -#elif defined(IEEE_ON) +#elif IEEE_754 test(fmt, randomDouble(1e-78)); /*OS390*/ #endif } diff --git a/icu4c/source/test/intltest/numrgts.cpp b/icu4c/source/test/intltest/numrgts.cpp index 0dc7eda3376..37817374b4a 100644 --- a/icu4c/source/test/intltest/numrgts.cpp +++ b/icu4c/source/test/intltest/numrgts.cpp @@ -1821,7 +1821,7 @@ NumberFormatRegressionTest::Test4162852(void) logln(UnicodeString("") + d + " -> " + '"' + s + '"' + " -> " + e); -#if !defined(OS390) || defined(IEEE_ON) +#if !defined(OS390) || IEEE_754 if (e != 0.0 || 1.0/e > 0.0) { #else if (e != 0.0) {