diff options
| author | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-04-09 17:45:32 +0200 |
|---|---|---|
| committer | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-04-09 17:45:32 +0200 |
| commit | 360243af92bd096522153521bce323f60bdb1b80 (patch) | |
| tree | e3b0e94099da7ce5e9d895e22e02435c61f205e0 /py/objcomplex.c | |
| parent | 5d06aa32609959115b496ac0e596438bfdbda038 (diff) | |
| parent | b87432b8fb8332548be11b63c9139065ce565f91 (diff) | |
Merge branch 'master' into nrf5_no_sdk
Diffstat (limited to 'py/objcomplex.c')
| -rw-r--r-- | py/objcomplex.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/objcomplex.c b/py/objcomplex.c index 426e76e5f..7ec47edb5 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -80,7 +80,7 @@ STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, si case 1: if (MP_OBJ_IS_STR(args[0])) { // a string, parse it - mp_uint_t l; + size_t l; const char *s = mp_obj_str_get_data(args[0], &l); return mp_parse_num_decimal(s, l, true, true, NULL); } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { @@ -117,6 +117,7 @@ STATIC mp_obj_t complex_unary_op(mp_uint_t op, mp_obj_t o_in) { mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in); switch (op) { case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->real != 0 || o->imag != 0); + case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mp_float_hash(o->real) ^ mp_float_hash(o->imag)); case MP_UNARY_OP_POSITIVE: return o_in; case MP_UNARY_OP_NEGATIVE: return mp_obj_new_complex(-o->real, -o->imag); default: return MP_OBJ_NULL; // op not supported |
