mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-5196 Don't divide by zero.
X-SVN-Rev: 19631
This commit is contained in:
parent
d9fe86302a
commit
e67193f2dc
1 changed files with 6 additions and 2 deletions
|
@ -80,13 +80,13 @@ static uint64_t randomInt64(void)
|
|||
static double randomDouble(void)
|
||||
{
|
||||
double ran = 0;
|
||||
int32_t i;
|
||||
|
||||
if (!initialized) {
|
||||
srand((unsigned)time(NULL));
|
||||
initialized = TRUE;
|
||||
}
|
||||
#if 0
|
||||
int32_t i;
|
||||
do {
|
||||
/* Assume rand has at least 12 bits of precision */
|
||||
for (i = 0; i < sizeof(ran); i += 1) {
|
||||
|
@ -95,7 +95,11 @@ static double randomDouble(void)
|
|||
} while (_isnan(ran));
|
||||
#else
|
||||
int64_t numerator = randomInt64();
|
||||
int64_t denomenator = randomInt64();
|
||||
int64_t denomenator;
|
||||
do {
|
||||
denomenator = randomInt64();
|
||||
}
|
||||
while (denomenator != 0);
|
||||
|
||||
ran = (double)numerator / (double)denomenator;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue