diff options
-rw-r--r-- | py/makeqstrdata.py | 5 | ||||
-rw-r--r-- | py/mpz.c | 6 | ||||
-rw-r--r-- | py/mpz.h | 4 | ||||
-rw-r--r-- | py/objint_mpz.c | 9 |
4 files changed, 16 insertions, 8 deletions
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 6ae229c734..02bfc5202b 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -1,5 +1,6 @@ import argparse import re +import sys # codepoint2name is different in Python 2 to Python 3 import platform @@ -37,7 +38,7 @@ def do_work(infiles): # verify line is of the correct form match = re.match(r'Q\((.+)\)$', line) if not match: - print('({}:{}) bad qstr format, got {}'.format(infile, line_number, line)) + print('({}:{}) bad qstr format, got {}'.format(infile, line_number, line), file=sys.stderr) return False # get the qstr value @@ -68,7 +69,7 @@ def main(): result = do_work(args.files) if not result: - print('exiting with error code') + print('exiting with error code', file=sys.stderr) exit(1) if __name__ == "__main__": @@ -1001,8 +1001,9 @@ machine_int_t mpz_as_int(const mpz_t *i) { return val; } -machine_float_t mpz_as_float(const mpz_t *i) { - machine_float_t val = 0; +#if MICROPY_ENABLE_FLOAT +mp_float_t mpz_as_float(const mpz_t *i) { + mp_float_t val = 0; mpz_dig_t *d = i->dig + i->len; while (--d >= i->dig) { @@ -1015,6 +1016,7 @@ machine_float_t mpz_as_float(const mpz_t *i) { return val; } +#endif uint mpz_as_str_size(const mpz_t *i, uint base) { if (base < 2 || base > 32) { @@ -65,7 +65,9 @@ mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs); mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs); machine_int_t mpz_as_int(const mpz_t *z); -machine_float_t mpz_as_float(const mpz_t *z); +#if MICROPY_ENABLE_FLOAT +mp_float_t mpz_as_float(const mpz_t *z); +#endif uint mpz_as_str_size(const mpz_t *z, uint base); char *mpz_as_str(const mpz_t *z, uint base); uint mpz_as_str_inpl(const mpz_t *z, uint base, char *str); diff --git a/py/objint_mpz.c b/py/objint_mpz.c index 6e1ee1a999..5cd4fb7bac 100644 --- a/py/objint_mpz.c +++ b/py/objint_mpz.c @@ -60,10 +60,13 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { return MP_OBJ_NULL; } - if (op == RT_BINARY_OP_TRUE_DIVIDE || op == RT_BINARY_OP_INPLACE_TRUE_DIVIDE) { - machine_float_t flhs = mpz_as_float(zlhs); - machine_float_t frhs = mpz_as_float(zrhs); + if (0) { +#if MICROPY_ENABLE_FLOAT + } else if (op == RT_BINARY_OP_TRUE_DIVIDE || op == RT_BINARY_OP_INPLACE_TRUE_DIVIDE) { + mp_float_t flhs = mpz_as_float(zlhs); + mp_float_t frhs = mpz_as_float(zrhs); return mp_obj_new_float(flhs / frhs); +#endif } else if (op <= RT_BINARY_OP_POWER) { mp_obj_int_t *res = mp_obj_int_new_mpz(); |