diff --git a/src/obj_long.c b/src/obj_long.c index 06a6c40b..eb28422b 100644 --- a/src/obj_long.c +++ b/src/obj_long.c @@ -1931,6 +1931,7 @@ KrkValue krk_int_from_float(double val) { if (exponent < 0) return INTEGER_VAL(0); if (exponent == 1024) return krk_runtimeError(vm.exceptions->valueError, "can not convert float %s to int", man ? "Nan" : "infinity"); + if (exponent < 47) return INTEGER_VAL(val); KrkLong _value; krk_long_init_si(&_value, 0x10000000000000 | man); diff --git a/src/obj_numeric.c b/src/obj_numeric.c index 2f42924a..0126e2ce 100644 --- a/src/obj_numeric.c +++ b/src/obj_numeric.c @@ -617,7 +617,7 @@ KRK_StaticMethod(float,__new__) { return krk_runtimeError(vm.exceptions->typeError, "%s() argument must be a string or a number, not '%T'", "float", argv[1]); } -KRK_Method(float,__int__) { return INTEGER_VAL(self); } +KRK_Method(float,__int__) { return krk_int_from_float(self); } KRK_Method(float,__float__) { return argv[0]; } static int isDigits(const char * c) {