• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with NSDecimalNumber truncating zeros
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with NSDecimalNumber truncating zeros


  • Subject: Re: Problem with NSDecimalNumber truncating zeros
  • From: Fritz Anderson <email@hidden>
  • Date: Mon, 6 Jul 2009 15:52:42 -0500

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
	22.00

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?

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 .


If you need to preserve context, you'll have to keep it yourself in another data structure (possibly one that wraps an NSDecimalNumber).

	— F


--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/ >


_______________________________________________

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


References: 
 >Problem with NSDecimalNumber truncating zeros (From: Eric Hermanson <email@hidden>)

  • Prev by Date: Re: CoreData deleteAll of kind
  • Next by Date: AsyncSocket. Troubles with MTMessageBroker didReceiveData
  • Previous by thread: Problem with NSDecimalNumber truncating zeros
  • Next by thread: Re: Problem with NSDecimalNumber truncating zeros
  • Index(es):
    • Date
    • Thread