JS: correct Double and Float conversions to Int (KT-8374 fixed)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user