[Wasm] Implement platform random in stdlib
This commit is contained in:
committed by
TeamCityServer
parent
1bdc9edb20
commit
9e00a2c5b4
+8
-2
@@ -5,5 +5,11 @@
|
||||
|
||||
package kotlin.random
|
||||
|
||||
internal actual fun defaultPlatformRandom(): Random = TODO("Wasm stdlib: Random")
|
||||
internal actual fun doubleFromParts(hi26: Int, low27: Int): Double = TODO("Wasm stdlib: Random")
|
||||
@JsFun("() => ((Math.random() * Math.pow(2, 32)) | 0)")
|
||||
private external fun initialSeed(): Int
|
||||
|
||||
internal actual fun defaultPlatformRandom(): Random =
|
||||
Random(initialSeed())
|
||||
|
||||
internal actual fun doubleFromParts(hi26: Int, low27: Int): Double =
|
||||
(hi26.toLong().shl(27) + low27) / (1L shl 53).toDouble()
|
||||
Reference in New Issue
Block a user