JS: correct Double and Float conversions to Int (KT-8374 fixed)

This commit is contained in:
Anton Bannykh
2017-10-05 15:11:01 +03:00
parent a52d719943
commit b5d32f420d
13 changed files with 126 additions and 39 deletions
+7 -1
View File
@@ -31,7 +31,7 @@ Kotlin.numberToLong = function (a) {
};
Kotlin.numberToInt = function (a) {
return a instanceof Kotlin.Long ? a.toInt() : (a | 0);
return a instanceof Kotlin.Long ? a.toInt() : Kotlin.doubleToInt(a);
};
Kotlin.numberToShort = function (a) {
@@ -50,6 +50,12 @@ Kotlin.numberToChar = function (a) {
return Kotlin.toChar(Kotlin.numberToInt(a));
};
Kotlin.doubleToInt = function(a) {
if (a > 2147483647) return 2147483647;
if (a < -2147483648) return -2147483648;
return a | 0;
};
Kotlin.toBoxedChar = function (a) {
if (a == null) return a;
if (a instanceof Kotlin.BoxedChar) return a;