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
This commit is contained in:
George Rhoten 2003-12-04 22:34:37 +00:00
parent 2be341254a
commit ea6b4709a1

View File

@ -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;
}