diff options
author | Damien George <damien.p.george@gmail.com> | 2020-02-14 12:26:46 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-02-18 13:04:36 +1100 |
commit | ce39c958ef0d948011ecb815ef0e7eb5ace9e288 (patch) | |
tree | 03dd03cc7c8c94f89853c6db6810d5f59cc37827 /py/mpz.c | |
parent | ac8383a95d3cf39f8d8433f5c58f62dd74536110 (diff) |
py: Factor out definition of mp_float_union_t to one location.
Diffstat (limited to 'py/mpz.c')
-rw-r--r-- | py/mpz.c | 17 |
1 files changed, 2 insertions, 15 deletions
@@ -771,20 +771,7 @@ void mpz_set_from_ll(mpz_t *z, long long val, bool is_signed) { #if MICROPY_PY_BUILTINS_FLOAT void mpz_set_from_float(mpz_t *z, mp_float_t src) { -#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE -typedef uint64_t mp_float_int_t; -#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -typedef uint32_t mp_float_int_t; -#endif - union { - mp_float_t f; - #if MP_ENDIANNESS_LITTLE - struct { mp_float_int_t frc:MP_FLOAT_FRAC_BITS, exp:MP_FLOAT_EXP_BITS, sgn:1; } p; - #else - struct { mp_float_int_t sgn:1, exp:MP_FLOAT_EXP_BITS, frc:MP_FLOAT_FRAC_BITS; } p; - #endif - } u = {src}; - + mp_float_union_t u = {src}; z->neg = u.p.sgn; if (u.p.exp == 0) { // value == 0 || value < 1 @@ -806,7 +793,7 @@ typedef uint32_t mp_float_int_t; const int dig_cnt = (adj_exp + 1 + (DIG_SIZE - 1)) / DIG_SIZE; const unsigned int rem = adj_exp % DIG_SIZE; int dig_ind, shft; - mp_float_int_t frc = u.p.frc | ((mp_float_int_t)1 << MP_FLOAT_FRAC_BITS); + mp_float_uint_t frc = u.p.frc | ((mp_float_uint_t)1 << MP_FLOAT_FRAC_BITS); if (adj_exp < MP_FLOAT_FRAC_BITS) { shft = 0; |