Fix for converting negative floating point to integer values.

This commit is contained in:
Pavel V. Talanov
2012-07-23 19:46:33 +04:00
parent 3ce9022f6b
commit 7de982ba2f
3 changed files with 62 additions and 3 deletions
@@ -18,6 +18,23 @@ fun box(): Boolean {
return false
}
val cn: Double = -3.6
if (cn.toDouble() != -3.6) {
return false
}
if (cn.toFloat() != -3.6.toFloat()) {
return false
}
if (cn.toByte() != -3.toByte()) {
return false
}
if (cn.toInt() != -3) {
return false
}
if (cn.toShort() != -3.toShort()) {
return false
}
val f: Float = 3.6.toFloat()
if (f.toDouble() != 3.6) {
return false
@@ -34,5 +51,22 @@ fun box(): Boolean {
if (f.toShort() != 3.toShort()) {
return false
}
val fn: Float = -3.6.toFloat()
if (fn.toDouble() != -3.6) {
return false
}
if (fn.toFloat() != -3.6.toFloat()) {
return false
}
if (fn.toByte() != -3.toByte()) {
return false
}
if (fn.toInt() != -3) {
return false
}
if (fn.toShort() != -3.toShort()) {
return false
}
return true
}
@@ -17,5 +17,12 @@ fun box(): Boolean {
if (c.toShort() != 3.toShort()) {
return false
}
val c2: Int = -5
if (c2.toShort() != -5.toShort()) {
return false
}
if (c2.toFloat() != -5.toFloat()) {
return false
}
return true
}