Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Eric Hermanson
Example: NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithMantissa: 2200LL exponent:-2 isNegative:NO]; This results in a decimal number that is represented both internally, and as a string, as 22 instead of the desired 22.00 Because of the functionali

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Fritz Anderson
On 6 Jul 2009, at 3:35 PM, Eric Hermanson wrote: Example: NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithMantissa:2200LL exponent:-2 isNegative:NO]; This results in a decimal number that is represented both internally, and as a string, as 22 instead of the desired

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Keary Suska
On Jul 6, 2009, at 2:35 PM, Eric Hermanson wrote: NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithMantissa:2200LL exponent:-2 isNegative:NO]; This results in a decimal number that is represented both internally, and as a string, as 22 instead of the desired

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Jack Repenning
On Jul 6, 2009, at 1:35 PM, Eric Hermanson wrote: Because of the functionality I am trying to achieve, I need to know the difference between 22 and 22.00, Perhaps -[NSDecimalNumberBehaviors scale] will help? -==- Jack Repenning jackrepenn...@tigris.org Project Owner SCPlugin http://scplugin

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Joel Norvell
Eric, I agree with Keary that NSNumberFormatter holds the solution to your problem. Here are links to pertinent documentation. HTH, Joel http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSFormatter_Class/Reference/Reference.html http://developer.apple.com/DOCUMENTA

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Eric Hermanson
First of all, this has absolutely nothing to do with NSNumberFormatter. 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 va

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Greg Guerin
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 p

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Michael Ash
On Mon, Jul 6, 2009 at 8:14 PM, Eric Hermanson wrote: > First of all, this has absolutely nothing to do with NSNumberFormatter. > > 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

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread WT
On Jul 6, 2009, at 10:35 PM, Eric Hermanson wrote: Because of the functionality I am trying to achieve, I need to know the difference between 22 and 22.00, but I can't figure out how to get NSDecimalNumber to retain the trailing zeros. Does anyone have advice? It looks like you need to e

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Kyle Sluder
On Mon, Jul 6, 2009 at 7:04 PM, WT wrote: > NSDecimalNumbers would be useless, if that were true. The whole point of > having NSDecimalNumbers is to be able to preserve precision. Seems like you're confusing precision with sigfigs. NSDecimalNumbers exist because IEEE floating point doesn't repres

Re: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Michael Ash
On Mon, Jul 6, 2009 at 10:04 PM, WT wrote: > On Jul 6, 2009, at 10:52 PM, Fritz Anderson wrote: > >> NSDecimalNumber just keeps numerical values, not their history. If two >> numbers, _as numbers_, are equal, you should expect the normalized internal >> representations to be identical. 22.00 == 22