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

objstr: Fix %d-formatting of floats.

parent 8a2cc1c7
No related branches found
No related tags found
No related merge requests found
...@@ -827,11 +827,7 @@ static bool arg_looks_numeric(mp_obj_t arg) { ...@@ -827,11 +827,7 @@ static bool arg_looks_numeric(mp_obj_t arg) {
static mp_obj_t arg_as_int(mp_obj_t arg) { static mp_obj_t arg_as_int(mp_obj_t arg) {
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) { if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) {
return mp_obj_new_int_from_float(mp_obj_get_float(arg));
// TODO: Needs a way to construct an mpz integer from a float
mp_int_t num = mp_obj_get_float(arg);
return MP_OBJ_NEW_SMALL_INT(num);
} }
#endif #endif
return arg; return arg;
......
...@@ -3,3 +3,8 @@ print(int(1418774543.)) ...@@ -3,3 +3,8 @@ print(int(1418774543.))
# TODO: General case with large exponent # TODO: General case with large exponent
#print(int(2.**100)) #print(int(2.**100))
print("%d" % 1418774543.)
# TODO: General case with large exponent
#print("%d" % 2.**100)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment