fix Math.natRandom for Windows build

This commit is contained in:
Joel Dice 2008-02-29 12:39:09 -07:00
parent 51a731847a
commit 3c237547ee

View File

@ -533,7 +533,12 @@ extern "C" JNIEXPORT jdouble JNICALL
Java_java_lang_Math_natRandom(JNIEnv*, jclass)
{
#ifdef WIN32
return rand();
int r = rand();
if (r == RAND_MAX) {
return 0;
} else {
return static_cast<double>(r) / static_cast<double>(RAND_MAX);
}
#else
return drand48();
#endif