Re: Float behaviour
Re: Float behaviour
- Subject: Re: Float behaviour
- From: Brian Smith <email@hidden>
- Date: Tue, 23 Aug 2005 08:33:06 +0800
Yes, they really need a cocoa class for this maybe they could call it
NSDecimalNumber;o)
Brian
On Aug 23, 2005, at 1:59 AM, ObjM2 wrote:
On Aug 23, 2005, at 2:19 AM, Richard Gray wrote:
If I were to convert $1 at an exchange rate of 1.2, I'd expect to get
1.2 units of the new currency yes? According to my currency
converter
however, 1 x 1.2 = 1.200000047683716
Can someone explain this behaviour to me and how to avoid it?
You'll need a BCD library (BCD = binary coded decimals => no
rounding errors)
http://en.wikipedia.org/wiki/Binary-coded_decimal
However, there is no support for BCDs amongst the generally
available C libraries, so you'll have to roll your own or use a
different language. COBOL uses BCDs by default. p1 Modula-2 for the
Mac has built-in BCD support, but no Cocoa support and it's not
free either.
ObjM2 when finished, will also have BCDs built-in, but that won't
help you right now.
It shouldn't be all too difficult to write a Cocoa class for BCDs
though.
_______________________________________________
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