LibJS: Always use AK::get_random() in Math.random()

Let AK deal with the underlying platform instead of having __serenity__
specific code in LibJS.
This commit is contained in:
Andreas Kling 2021-08-30 13:52:59 +02:00
parent 47420e72b8
commit eaf904000f
Notes: sideshowbarker 2024-07-18 05:05:14 +09:00

View File

@ -96,11 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::abs)
// 21.3.2.27 Math.random ( ), https://tc39.es/ecma262/#sec-math.random
JS_DEFINE_NATIVE_FUNCTION(MathObject::random)
{
#ifdef __serenity__
double r = (double)get_random<u32>() / (double)UINT32_MAX;
#else
double r = (double)rand() / (double)RAND_MAX;
#endif
return Value(r);
}