Re: Recommendation for keeping track of money in Core Data
Re: Recommendation for keeping track of money in Core Data
- Subject: Re: Recommendation for keeping track of money in Core Data
- From: Jeff LaMarche <email@hidden>
- Date: Mon, 16 Jan 2006 22:04:20 -0500
On Jan 16, 2006, at 9:44 PM, Jeff Laing wrote:
You end up dealing with "23.29999999999999999" or "23.300000000001"
instead
of "23.3".
But do you get the wrong result if you're using a number formatter
(using the new behavior with 10.4) to display the number as currency
using two decimal places? If my understanding is correct, the answer
is no. The loss of precision would take dozens or maybe even hundreds
of calculations between roundings in order to cause a discrepancy of
even $0.01.
Or am I missing something (I certainly could be)? While in memory,
the value is stored as an NSNumber, not as a raw float, so only when
the number is stored or loaded will the loss of precision come into
play, right?
I'm not a mathematician, so I'll defer to you if you say it matters
with Core Data, but I have trouble seeing many situations where the
loss of precision that comes into play when the data gets read from
or written to disk would actually cause a wrong result if you're
using a number formatter to display the value with two decimal places
and given that while in memory, the value is going to be represented
by an NSNumber.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden