Added missing implementations of Random's methods. (#1983)

This commit is contained in:
Sergey Bogolepov
2018-08-31 16:20:15 +03:00
committed by GitHub
parent 6750ef59bb
commit 97a423c781
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -21,6 +21,6 @@ remoteRoot=konan_tests
testDataVersion=1226829:id
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_13M2_CompilerAllPlugins),number:1.3-M2-release-211,tag:kotlin-native,pinned:true,branch:(default:any)/artifacts/content/maven
kotlinVersion=1.3-M2-release-211
testKotlinVersion=1.3-M2-release-203
testKotlinVersion=1.3-M2-release-214
konanVersion=0.9
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
@@ -59,14 +59,18 @@ public abstract class NativeRandom {
*/
override fun nextLong(): Long = (nextInt().toLong() shl 32) + nextInt().toLong()
override fun nextBits(bitCount: Int): Int = TODO("unimplemented")
override fun nextBits(bitCount: Int): Int =
nextInt().takeUpperBits(bitCount)
}
}
internal actual fun defaultPlatformRandom(): Random = NativeRandom
internal actual fun fastLog2(value: Int): Int = TODO("unimplemented")
internal actual fun doubleFromParts(hi26: Int, low27: Int): Double = TODO("unimplemented")
internal actual fun fastLog2(value: Int): Int =
31 - value.numberOfLeadingZeros()
internal actual fun doubleFromParts(hi26: Int, low27: Int): Double =
(hi26.toLong().shl(27) + low27) / (1L shl 53).toDouble()
// TODO: common stdlib Random hasn't got seed, this is workaround for running K/N tests.
var Random.seed:Long