Re: Problem with NSDecimalNumber truncating zeros
Re: Problem with NSDecimalNumber truncating zeros
- Subject: Re: Problem with NSDecimalNumber truncating zeros
- From: Greg Guerin <email@hidden>
- Date: Mon, 6 Jul 2009 18:57:07 -0700
Eric Hermanson wrote:
Second of all, the NSDecimalNumber is losing information it had
when I constructed it, which I do not want it to lose. Instead of
storing an exponent of -2 and a mantissa of 2200, it instead
chooses to normalize the values to 0 and 22, respectively. While
this does provide equal numbers as far as isEqual is concerned, I
am forced to store my own context separately if I want the number
to remember the scale it had when I constructed it. This is
unfortunate.
If the NSDecimalNumber class doesn't meet your needs, consider using
the C struct NSDecimal and the family of C functions found in
NSDecimal.h. You should look carefully at the details of the struct
first. Understanding the representation is crucial to knowing what
is possible in distinguishing values from one another.
http://developer.apple.com/documentation/Cocoa/Conceptual/
NumbersandValues/Articles/DecimalNumbers.html
I found the above simply by starting at the NSDecimalNumber class
reference and clicking the link to the Companion Guide, where the
"Using Decimal Numbers" heading is visible.
If NSDecimal still doesn't meet your needs, try these google keywords:
bignum
objective-c bignum
bigdecimal
Also see the list of libraries at the end of this article:
http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic
-- GG
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden