PythonExtra/tests/extmod/uctypes_native_float.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
321 B
Python
Raw Permalink Normal View History

2017-02-14 23:56:22 +01:00
try:
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
desc = {
"f32": uctypes.FLOAT32 | 0,
"f64": uctypes.FLOAT64 | 0,
}
data = bytearray(8)
S = uctypes.struct(uctypes.addressof(data), desc, uctypes.NATIVE)
S.f32 = 12.34
print("%.4f" % S.f32)
S.f64 = 12.34
print("%.4f" % S.f64)