Skip to content

Commit 64ef5d7

Browse files
committed
Change pfenv_print_int to take machine_uint_t rather than unsinged in
With this change, the following works: >>> print('%#x' % 0x1234567890abcdef) 0x1234567890abcdef
1 parent f81a49e commit 64ef5d7

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

py/pfenv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, in
7979
// We can use 16 characters for 32-bit and 32 characters for 64-bit
8080
#define INT_BUF_SIZE (sizeof(machine_int_t) * 4)
8181

82-
int pfenv_print_int(const pfenv_t *pfenv, unsigned int x, int sgn, int base, int base_char, int flags, char fill, int width) {
82+
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) {
8383
char sign = 0;
8484
if (sgn) {
85-
if ((int)x < 0) {
85+
if ((machine_int_t)x < 0) {
8686
sign = '-';
8787
x = -x;
8888
} else if (flags & PF_FLAG_SHOW_SIGN) {

py/pfenv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef struct _pfenv_t {
1717
void pfenv_vstr_add_strn(void *data, const char *str, unsigned int len);
1818

1919
int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, int flags, char fill, int width);
20-
int pfenv_print_int(const pfenv_t *pfenv, unsigned int x, int sgn, int base, int base_char, int flags, char fill, int width);
20+
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);
2121
#if MICROPY_ENABLE_FLOAT
2222
int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, char fill, int width, int prec);
2323
#endif

0 commit comments

Comments
 (0)