Skip to content
Snippets Groups Projects
Commit 776883cb authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

py/objint_longlong: Implement mp_obj_int_from_bytes_impl().

This makes int.from_bytes() work for MICROPY_LONGINT_IMPL_LONGLONG.
parent bc5bffbf
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,17 @@ const mp_obj_int_t mp_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX}; ...@@ -54,7 +54,17 @@ const mp_obj_int_t mp_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX};
#endif #endif
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf) { mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf) {
mp_not_implemented(""); int delta = 1;
if (!big_endian) {
buf += len - 1;
delta = -1;
}
mp_longint_impl_t value = 0;
for (; len--; buf += delta) {
value = (value << 8) | *buf;
}
return mp_obj_new_int_from_ll(value);
} }
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) { void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment