From ea6b4709a14214e30a7a4a59da973538773d67ae Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Thu, 4 Dec 2003 22:34:37 +0000 Subject: [PATCH] ICU-2962 Fix a rare case where numbers are getting out of range. The original fix modified the value. Now it modifies the range. X-SVN-Rev: 14005 --- icu4c/source/test/intltest/tsnmfmt.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/icu4c/source/test/intltest/tsnmfmt.cpp b/icu4c/source/test/intltest/tsnmfmt.cpp index 3b7c1387587..ee7314520a9 100644 --- a/icu4c/source/test/intltest/tsnmfmt.cpp +++ b/icu4c/source/test/intltest/tsnmfmt.cpp @@ -132,13 +132,15 @@ uint32_t IntlTestNumberFormat::randLong() } -/* Make sure that we don't get something too large and multiply into infinity. */ +/* Make sure that we don't get something too large and multiply into infinity. + @param smallerThanMax the requested maximum value smaller than DBL_MAX */ double IntlTestNumberFormat::getSafeDouble(double smallerThanMax) { double it; + double high = (DBL_MAX/smallerThanMax)/10.0; + double low = -high; do { it = randDouble(); - } while (-DBL_MAX/smallerThanMax > it || it > DBL_MAX/smallerThanMax); - it *= smallerThanMax/10.0; + } while (low > it || it > high); return it; }