From 2d15deebdcf7d6fb8f78907e0c6ca9cb9c2aa000 Mon Sep 17 00:00:00 2001 From: Rachel Dowdall Date: Sat, 22 Mar 2014 20:29:56 +0000 Subject: Fixed floor division on mp ints and small ints. Added a floordivide test case. --- py/runtime.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'py/runtime.c') diff --git a/py/runtime.c b/py/runtime.c index 95c3a4415..94f319056 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "nlr.h" #include "misc.h" @@ -661,7 +662,11 @@ mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { break; } case RT_BINARY_OP_FLOOR_DIVIDE: - case RT_BINARY_OP_INPLACE_FLOOR_DIVIDE: lhs_val /= rhs_val; break; + case RT_BINARY_OP_INPLACE_FLOOR_DIVIDE: + { + lhs_val = python_floor_divide(lhs_val, rhs_val); + break; + } #if MICROPY_ENABLE_FLOAT case RT_BINARY_OP_TRUE_DIVIDE: case RT_BINARY_OP_INPLACE_TRUE_DIVIDE: return mp_obj_new_float((mp_float_t)lhs_val / (mp_float_t)rhs_val); -- cgit v1.2.3