mirror of
https://github.com/corda/corda.git
synced 2025-06-17 22:58:19 +00:00
Implemented java.lang.Math.random() properly (seeding the random number
on first use, and then using the system random number generator)
This commit is contained in:
@ -136,6 +136,26 @@ Java_java_lang_Math_pow(JNIEnv*, jclass, jdouble val, jdouble exp)
|
||||
return pow(val, exp);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_java_lang_Math_natRandomInitialize(JNIEnv*, jclass, jlong val)
|
||||
{
|
||||
#ifdef WIN32
|
||||
srand(val);
|
||||
#else
|
||||
srand48(val);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
Java_java_lang_Math_natRandom(JNIEnv*, jclass)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return rand();
|
||||
#else
|
||||
return drand48();
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
Java_java_lang_Math_floor(JNIEnv*, jclass, jdouble val)
|
||||
{
|
||||
|
Reference in New Issue
Block a user