1 Star 0 Fork 11

chenchi/microPython

forked from QuecPython/microPython 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
float_struct.py 515 Bytes
一键复制 编辑 原始数据 按行查看 历史
chenchi 提交于 2024-03-02 15:23 +08:00 . initial commit.
# test struct package with floats
try:
try:
import ustruct as struct
except:
import struct
except ImportError:
print("SKIP")
raise SystemExit
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"):
x = struct.pack(fmt, i)
v = struct.unpack(fmt, x)[0]
print("%2s: %.17f - %s" % (fmt, v, (i == v) and "passed" or "failed"))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/brian_chenchi/microPython.git
git@gitee.com:brian_chenchi/microPython.git
brian_chenchi
microPython
microPython
master

搜索帮助