Add xorwow random implementation test and fix implementation

This commit is contained in:
Ilya Gorbunov
2018-07-05 05:32:45 +03:00
parent 042a8ff6a2
commit ed1f869354
5 changed files with 62 additions and 29 deletions
@@ -5,10 +5,8 @@
package kotlin.random
import kotlin.math.pow
internal actual fun defaultPlatformRandom(): Random =
XorWowRandom((js("Math").random().unsafeCast<Double>() * (2.0.pow(32.0))).toInt())
Random(js("(Math.random() * Math.pow(2, 32)) | 0").unsafeCast<Int>())
internal actual fun fastLog2(value: Int): Int {