gpt4 book ai didi

iPhone - 通过 CoreData 将 float 存储在 SQLite 中

转载 作者:行者123 更新时间:2023-12-03 16:26:17 26 4
gpt4 key购买 nike

我在 SQLite 中存储一个 float (通过核心数据),如下所示:

unit.conversion = [NSNumber numberWithFloat:0.001];

当我查看 SQLite 数据库时,该值为 0.0010000000474974513

unit.conversion 是我的数据模型中的可选 float ...

这有什么问题吗?

谢谢

最佳答案

float 并不(总是)精确表示 - 它们是近似值。

参见What Every Computer Scientist Should Know About Floating-Point Arithmetic作为背景。

关于iPhone - 通过 CoreData 将 float 存储在 SQLite 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3765043/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com