核心数据 - 货币的十进制类型

时间:2021-10-05 16:17:27

I read in a recent post that the Decimal data type is the best to use in Core Data to model currency since it doesn't have floating point issues.

我在最近的一篇文章中读到,Decimal数据类型最适合在Core Data中用于模型货币,因为它没有浮点问题。

I've searched the apple docs and google and can't seem to find any documentation on using the Decimal type.

我搜索了苹果文档和谷歌,似乎无法找到有关使用Decimal类型的任何文档。

Does anyone have a link to documentation on it?

有没有人有关于它的文档的链接?

Thanks!

谢谢!

3 个解决方案

#1


19  

Use "Decimal" as the attribute type in your data model and NSDecimalNumber as the object type in your code.

使用“Decimal”作为数据模型中的属性类型,使用NSDecimalNumber作为代码中的对象类型。

#2


7  

The 'decimal' type in Core Data relates to the Cocoa type NSDecimalNumber, and lo, here is its documentation: NSDecimalNumber documentation :-)

Core Data中的'decimal'类型与Cocoa类型NSDecimalNumber有关,而lo,这里是它的文档:NSDecimalNumber文档:-)

#3


4  

Its because we don't want to get things like $9.9999999998 instead of $10.

这是因为我们不想得到$ 9.9999999998而不是10美元。

More Details:

更多细节:

https://*.com/a/17107017/1239426

https://*.com/a/17107017/1239426

#1


19  

Use "Decimal" as the attribute type in your data model and NSDecimalNumber as the object type in your code.

使用“Decimal”作为数据模型中的属性类型,使用NSDecimalNumber作为代码中的对象类型。

#2


7  

The 'decimal' type in Core Data relates to the Cocoa type NSDecimalNumber, and lo, here is its documentation: NSDecimalNumber documentation :-)

Core Data中的'decimal'类型与Cocoa类型NSDecimalNumber有关,而lo,这里是它的文档:NSDecimalNumber文档:-)

#3


4  

Its because we don't want to get things like $9.9999999998 instead of $10.

这是因为我们不想得到$ 9.9999999998而不是10美元。

More Details:

更多细节:

https://*.com/a/17107017/1239426

https://*.com/a/17107017/1239426