From 3c237547ee290f6edf596d6ea6cd4c6aab45570b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 29 Feb 2008 12:39:09 -0700 Subject: [PATCH] fix Math.natRandom for Windows build --- classpath/java-lang.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index be5b7408aa..adaff8bdac 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -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(r) / static_cast(RAND_MAX); + } #else return drand48(); #endif