summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
diff options
context:
space:
mode:
authorRachel Dowdall <rjdowdall@gmail.com>2014-03-22 20:19:24 +0000
committerRachel Dowdall <rjdowdall@gmail.com>2014-03-22 20:19:24 +0000
commit56402796d87f75fbb9e42fc9e3c0adc027fb7c98 (patch)
tree0e0c0b1effb4a86ec2f5c0326626db2061f3cb8a /py/runtime.c
parentcde8631f15db9941986f8d04534e52462a76094b (diff)
downloadmicropython-56402796d87f75fbb9e42fc9e3c0adc027fb7c98.tar.gz
micropython-56402796d87f75fbb9e42fc9e3c0adc027fb7c98.zip
Fixed floor division on mp ints and small ints. Added a floordivide test case.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 95c3a44159..94f3190566 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include <math.h>
#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);