summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorDavid Steinberg <david.steinberg.dev@gmail.com>2015-01-25 02:50:34 +0000
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-01-27 22:49:01 +0200
commit0b3014ce3ac381e886c956137e4e5475061a5ddc (patch)
tree097119f39c66ffbb4228bef58e459cd49a2b106f /tests
parenta5efcd474563ed4e3d979a619f073abab8379a09 (diff)
downloadmicropython-0b3014ce3ac381e886c956137e4e5475061a5ddc.tar.gz
micropython-0b3014ce3ac381e886c956137e4e5475061a5ddc.zip
py: Add support for floats in mp_binary_{get,set}_val()
- This then provides support for floats in the struct package
Diffstat (limited to 'tests')
-rw-r--r--tests/float/float_struct.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py
new file mode 100644
index 0000000000..8ad0e492c6
--- /dev/null
+++ b/tests/float/float_struct.py
@@ -0,0 +1,12 @@
+# test struct package with floats
+
+import struct
+
+i = 1. + 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'):
+ x = struct.pack(fmt, i)
+ v = struct.unpack(fmt, x)[0]
+ print('%2s: %.17f - %s' % (fmt, v, (i == v) and 'passed' or 'failed'))
+