diff options
author | Dave Hylands <dhylands@gmail.com> | 2014-04-07 13:44:12 -0700 |
---|---|---|
committer | Dave Hylands <dhylands@gmail.com> | 2014-04-07 13:47:04 -0700 |
commit | 23dc6d0aceba51756f01e96c099678c38b4a88f9 (patch) | |
tree | 19fc2bf583a690f2b17c10557f5976544e126c6b | |
parent | c4029e5079126585e4616f1d511d94318e1f1700 (diff) | |
download | micropython-23dc6d0aceba51756f01e96c099678c38b4a88f9.tar.gz micropython-23dc6d0aceba51756f01e96c099678c38b4a88f9.zip |
Fix truncation problem when using longlong implementation.
-rw-r--r-- | py/objint.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/py/objint.c b/py/objint.c index 012ce288c7..e1b67a16b3 100644 --- a/py/objint.c +++ b/py/objint.c @@ -115,7 +115,17 @@ char *mp_obj_int_formatted(char **buf, int *buf_size, int *fmt_size, mp_obj_t se *fmt_size = 0; return *buf; } - fmt_int_t num = mp_obj_get_int(self_in); + fmt_int_t num; +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG + mp_obj_int_t *self = self_in; + if (MP_OBJ_IS_TYPE(self_in, &mp_type_int)) { + // mp_obj_get_int truncates to machine_int_t + num = self->val; + } else +#endif + { + num = mp_obj_get_int(self_in); + } char sign = '\0'; if (num < 0) { num = -num; |