diff options
author | Matthias Urlichs <matthias@urlichs.de> | 2023-10-25 19:17:47 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-03-20 14:13:49 +1100 |
commit | e520fa2e0fb3cfafe27a1f9e7e9b230dd58d7a33 (patch) | |
tree | 0a1ddb9be05b6bea10af06c6d69620fc8c63acb9 /tests/float/float_struct.py | |
parent | 77f08b72caeb26c7e3be5975d976e77d44099d43 (diff) |
py/binary: Support half-float 'e' format in struct pack/unpack.
This commit implements the 'e' half-float format: 10-bit mantissa, 5-bit
exponent. It uses native _Float16 if supported by the compiler, otherwise
uses custom bitshifting encoding/decoding routines.
Signed-off-by: Matthias Urlichs <matthias@urlichs.de>
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/float/float_struct.py')
-rw-r--r-- | tests/float/float_struct.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py index 47fe40501..6e282a6af 100644 --- a/tests/float/float_struct.py +++ b/tests/float/float_struct.py @@ -8,7 +8,7 @@ except ImportError: i = 1.0 + 1 / 2 # TODO: it looks like '=' format modifier is not yet supported # for fmt in ('f', 'd', '>f', '>d', '<f', '<d', '=f', '=d'): -for fmt in ("f", "d", ">f", ">d", "<f", "<d"): +for fmt in ("e", "f", "d", ">e", ">f", ">d", "<e", "<f", "<d"): x = struct.pack(fmt, i) v = struct.unpack(fmt, x)[0] print("%2s: %.17f - %s" % (fmt, v, (i == v) and "passed" or "failed")) |