Update pocketpy.cpp

This commit is contained in:
BLUELOVETH 2024-03-28 19:42:52 +08:00 committed by GitHub
parent 6486a497a9
commit e3a8d05ba6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -444,8 +444,8 @@ void init_builtins(VM* _vm) {
return VAR(_CAST(i64, _0) % rhs);
});
_vm->bind(_vm->_t(VM::tp_int), "bit_length(self)", [](VM* vm, ArgsView args) {
i64 x = CAST(i64, args[0]);
_vm->bind_method<0>(VM::tp_int, "bit_length", [](VM* vm, ArgsView args) {
i64 x = _CAST(i64, args[0]);
if(x < 0) x = -x;
int bits = 0;
while(x){ x >>= 1; bits++; }
@ -1633,4 +1633,4 @@ CodeObject_ VM::compile(std::string_view source, const Str& filename, CompileMod
}
}
} // namespace pkpy
} // namespace pkpy