mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
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:
parent
47420e72b8
commit
eaf904000f
Notes:
sideshowbarker
2024-07-18 05:05:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/eaf904000fa
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user