Fix floating point conversions to match Kotlin/JVM
(cherry picked from commit de078d6)
This commit is contained in:
committed by
Pavel Punegov
parent
df41389ef7
commit
cc89dc2754
@@ -0,0 +1,29 @@
|
||||
package runtime.basic.ieee754
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val v = Float.POSITIVE_INFINITY
|
||||
val i = v.toInt()
|
||||
println("$v $i ${v.toShort()} ${i.toShort()}")
|
||||
|
||||
val a = 42
|
||||
val b = Float.MAX_VALUE
|
||||
println("${a + b}")
|
||||
|
||||
val s = Float.NaN.toShort()
|
||||
println("NAN2SHORT:: $s")
|
||||
|
||||
val d: Float = Float.MAX_VALUE
|
||||
println("MAX2SHORT:: ${d.toShort()}")
|
||||
val d2i = d.toInt()
|
||||
println("$d2i ${d2i.toShort()}")
|
||||
|
||||
for (f in arrayOf(Float.POSITIVE_INFINITY, Float.MAX_VALUE / 2, Float.MAX_VALUE,
|
||||
3.14f, Float.NaN, -33333.12312f, Float.MIN_VALUE, Float.NEGATIVE_INFINITY,
|
||||
-1.2f, -12.6f, 2.3f)) {
|
||||
println("FLOAT:: $f INT:: ${f.toInt()}")
|
||||
}
|
||||
|
||||
println("OK")
|
||||
}
|
||||
Reference in New Issue
Block a user