summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-22 17:34:09 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-22 17:34:09 +0000
commit0379b55ab036921eaee96f07385d2329d8de97fd (patch)
tree881478b9ebcb231026161046d22d23e31e7e771d /py
parentb25ef4db3b138c47b495bc3299b45a2ac966cf67 (diff)
downloadmicropython-0379b55ab036921eaee96f07385d2329d8de97fd.tar.gz
micropython-0379b55ab036921eaee96f07385d2329d8de97fd.zip
py: Fix casting and printing of small int.
Diffstat (limited to 'py')
-rw-r--r--py/objint.c2
-rw-r--r--py/objint_longlong.c2
-rw-r--r--py/showbc.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/py/objint.c b/py/objint.c
index b33557b64d..775e5644d0 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -47,7 +47,7 @@ STATIC mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
void int_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
if (MP_OBJ_IS_SMALL_INT(self_in)) {
- print(env, "%d", (int)MP_OBJ_SMALL_INT_VALUE(self_in));
+ print(env, INT_FMT, MP_OBJ_SMALL_INT_VALUE(self_in));
}
}
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index ea28bc7d9a..d07f72a555 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -23,7 +23,7 @@
void int_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
if (MP_OBJ_IS_SMALL_INT(self_in)) {
- print(env, "%d", (int)MP_OBJ_SMALL_INT_VALUE(self_in));
+ print(env, INT_FMT, MP_OBJ_SMALL_INT_VALUE(self_in));
} else {
mp_obj_int_t *self = self_in;
print(env, "%lld" SUFFIX, self->val);
diff --git a/py/showbc.c b/py/showbc.c
index 4bee97650a..609048e8f6 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -68,7 +68,7 @@ void mp_byte_code_print(const byte *ip, int len) {
break;
case MP_BC_LOAD_CONST_SMALL_INT: {
- int num = 0;
+ machine_int_t num = 0;
if ((ip[0] & 0x40) != 0) {
// Number is negative
num--;
@@ -76,7 +76,7 @@ void mp_byte_code_print(const byte *ip, int len) {
do {
num = (num << 7) | (*ip & 0x7f);
} while ((*ip++ & 0x80) != 0);
- printf("LOAD_CONST_SMALL_INT %d", num);
+ printf("LOAD_CONST_SMALL_INT " INT_FMT, num);
break;
}