diff options
author | Damien George <damien.p.george@gmail.com> | 2014-03-22 20:25:55 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-03-22 20:25:55 +0000 |
commit | 365274da13cc701e3e8f6c72a24dd4eb4083a88d (patch) | |
tree | 110170545eae9de4a584f08dd34d259cef0b70a0 /py/objfloat.c | |
parent | 0119fc7532c573bd596fb6173b4d36ef5260027a (diff) | |
parent | a6d53188b7db85af9dc93186e4f36b7009084ea6 (diff) | |
download | micropython-365274da13cc701e3e8f6c72a24dd4eb4083a88d.tar.gz micropython-365274da13cc701e3e8f6c72a24dd4eb4083a88d.zip |
Merge branch 'master' of github.com:micropython/micropython
Diffstat (limited to 'py/objfloat.c')
-rw-r--r-- | py/objfloat.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/py/objfloat.c b/py/objfloat.c index c51e13e7a1..c4567c4a38 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -1,5 +1,6 @@ #include <stdlib.h> #include <assert.h> +#include <math.h> #include "nlr.h" #include "misc.h" @@ -107,8 +108,12 @@ mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs_in) { case RT_BINARY_OP_INPLACE_FLOOR_DIVIDE: val = lhs_val / rhs_val; break; */ case RT_BINARY_OP_TRUE_DIVIDE: - case RT_BINARY_OP_INPLACE_TRUE_DIVIDE: lhs_val /= rhs_val; break; - + case RT_BINARY_OP_INPLACE_TRUE_DIVIDE: + lhs_val /= rhs_val; + if (isinf(lhs_val)){ // check for division by zero + nlr_jump(mp_obj_new_exception_msg(&mp_type_ZeroDivisionError, "float division by zero")); + } + break; case RT_BINARY_OP_LESS: return MP_BOOL(lhs_val < rhs_val); case RT_BINARY_OP_MORE: return MP_BOOL(lhs_val > rhs_val); case RT_BINARY_OP_LESS_EQUAL: return MP_BOOL(lhs_val <= rhs_val); |