diff options
| author | Limor "Ladyada" Fried <limor@ladyada.net> | 2021-01-09 12:25:16 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-09 12:25:16 -0500 |
| commit | 9253351fa4cf8890ec7771b0012b6cb7b8e35302 (patch) | |
| tree | abe590fea814397733fd44de0cab724bcb0f86c8 /py/objfloat.c | |
| parent | 999ee68e12877e6b2188a821fd43efc1567279fe (diff) | |
| parent | 55c80754c76a115e2f128931a408e6702aee6ef4 (diff) | |
Merge branch 'main' into main
Diffstat (limited to 'py/objfloat.c')
| -rw-r--r-- | py/objfloat.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/py/objfloat.c b/py/objfloat.c index 59f1eb2f6..80f10e816 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -333,6 +333,13 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t return mp_obj_new_float(lhs_val); } +// Convert a uint64_t to a 32-bit float without invoking the double-precision math routines, +// which are large. +mp_float_t uint64_to_float(uint64_t ui64) { + // 4294967296 = 2^32 + return (mp_float_t) ((uint32_t) (ui64 >> 32) * 4294967296.0f + (uint32_t) (ui64 & 0xffffffff)); +} + #pragma GCC diagnostic pop #endif // MICROPY_PY_BUILTINS_FLOAT |
