nsdecimal

When is it better to use an NSDecimal, NSDecimalNumber instead of a double?

自古美人都是妖i 提交于 2020-01-14 10:27:32
问题 For simple uses, such as tracking weight values like 65.1kg, is there any benefit of going with NSDecimal/NSDecimalNumber over double? My understanding here is double (or even float) provides more than enough precision in such cases. Please correct me if I'm wrong. 回答1: First, read Josh Caswell's link. It it especially critical when working with money. In your case it may matter or may not, depending on your goal. If you put in 65.1 and you want to get exactly 65.1 back out, then you