2017-02-14 17:56:22 -05:00
|
|
|
try:
|
|
|
|
import uctypes
|
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
2017-06-10 13:14:16 -04:00
|
|
|
raise SystemExit
|
2016-03-19 17:59:42 -04:00
|
|
|
|
|
|
|
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)
|