• 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: How to pretty print (big)numbers?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pretty print (big)numbers?


  • Subject: Re: How to pretty print (big)numbers?
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sat, 11 Oct 2014 14:06:18 +0700

On 11 Oct 2014, at 13:44, Greg Parker <email@hidden> wrote:

>
>> On Oct 10, 2014, at 11:03 PM, Gerriet M. Denkmann <email@hidden> wrote:
>>
>> On iOS 8.0:
>>
>> UInt64 sum = 16494631536958186120UL;
>> NSString *sumString = 	[ NSNumberFormatter	localizedStringFromNumber:	@(sum)
>> 										numberStyle: 				NSNumberFormatterDecimalStyle
>> 					];
>> results in sumString =  -1,952,112,536,751,365,496, which seems not quite right.
>>
>> How can I convince NSNumberFormatter that it should print unsigned integers?
>
> You can't. Sorry.
>
> NSNumberFormatter is built atop ICU. ICU's API can handle signed 64-bit integers but not unsigned 64-bit integers.

There is a (sort of) work-around:
double dSum = sum;
NSString *stringWithDigitsLost = 	[ NSNumberFormatter	localizedStringFromNumber:	@(dSum)
												numberStyle: 				NSNumberFormatterDecimalStyle
							];
stringWithDigitsLost	= 16,494,631,536,958,200,000
correctString:		= 16 494 631 536 958 186 120


Kind regards,

Gerriet.



_______________________________________________

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: 
 >How to pretty print (big)numbers? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to pretty print (big)numbers? (From: Greg Parker <email@hidden>)

  • Prev by Date: Re: How to pretty print (big)numbers?
  • Next by Date: Re: How to pretty print (big)numbers?
  • Previous by thread: Re: How to pretty print (big)numbers?
  • Next by thread: Re: How to pretty print (big)numbers?
  • Index(es):
    • Date
    • Thread