Use krk_int_from_float for float.__int__, shortcircuit small enough values
This commit is contained in:
parent
114b66dd5c
commit
484f0f68a1
@ -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);
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user