diff options
author | Dave Hylands <dhylands@gmail.com> | 2014-04-05 09:42:20 -0700 |
---|---|---|
committer | Dave Hylands <dhylands@gmail.com> | 2014-04-05 09:42:20 -0700 |
commit | 64ef5d7f4eefeecb8ee554cbaf1f9641b35a88bf (patch) | |
tree | b5cfea239c52091d314c5f9d567c83d1ee7ed4ba /py | |
parent | f81a49e464c2899710b3ed1f402434f83d92d094 (diff) | |
download | micropython-64ef5d7f4eefeecb8ee554cbaf1f9641b35a88bf.tar.gz micropython-64ef5d7f4eefeecb8ee554cbaf1f9641b35a88bf.zip |
Change pfenv_print_int to take machine_uint_t rather than unsinged in
With this change, the following works:
>>> print('%#x' % 0x1234567890abcdef)
0x1234567890abcdef
Diffstat (limited to 'py')
-rw-r--r-- | py/pfenv.c | 4 | ||||
-rw-r--r-- | py/pfenv.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/py/pfenv.c b/py/pfenv.c index 7ce721aca1..0d6fab3c48 100644 --- a/py/pfenv.c +++ b/py/pfenv.c @@ -79,10 +79,10 @@ int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, in // We can use 16 characters for 32-bit and 32 characters for 64-bit #define INT_BUF_SIZE (sizeof(machine_int_t) * 4) -int pfenv_print_int(const pfenv_t *pfenv, unsigned int x, int sgn, int base, int base_char, int flags, char fill, int width) { +int pfenv_print_int(const pfenv_t *pfenv, machine_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) { char sign = 0; if (sgn) { - if ((int)x < 0) { + if ((machine_int_t)x < 0) { sign = '-'; x = -x; } else if (flags & PF_FLAG_SHOW_SIGN) { diff --git a/py/pfenv.h b/py/pfenv.h index edceaf3e4e..36b452b91c 100644 --- a/py/pfenv.h +++ b/py/pfenv.h @@ -17,7 +17,7 @@ typedef struct _pfenv_t { void pfenv_vstr_add_strn(void *data, const char *str, unsigned int len); int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, int flags, char fill, int width); -int pfenv_print_int(const pfenv_t *pfenv, unsigned int x, int sgn, int base, int base_char, int flags, char fill, int width); +int pfenv_print_int(const pfenv_t *pfenv, machine_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width); #if MICROPY_ENABLE_FLOAT int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, char fill, int width, int prec); #endif |