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