Re: Repetitive Appending of Strings
Re: Repetitive Appending of Strings
- Subject: Re: Repetitive Appending of Strings
- From: glenn andreas <email@hidden>
- Date: Tue, 12 Feb 2008 13:05:43 -0600
On Feb 12, 2008, at 12:21 PM, Andrew Merenbach wrote:
Hi, Glenn and John,
I have a better idea of what I'll need to do now. I get the feeling
that, since the only method call in the loop is the line in
question, that will be the slow part. When users try to output
hundreds of thousands of digits (not really that useful, most
likely, but something which I feel should be supported -- if only
for completeness), it might be a good idea to use a buffer, yes.
If what you're trying to do is to basically allow the user to specify
(at run time) the precision of the number, you could just do:
[NSString stringWithFormat: [NSString stringWithFormat: @"%%ß",
numberOfDigits], n]
which will make the format string dynamically. So if numberOfDigits
were 1000, it would be equivalent to [NSString stringWithFormat:
@"00f", n] (with the exact format string with regards to decimal
places and the like left as an exercise for the reader and time spent
with the numeric formating page). And of course, asking for even 100
decimal places is pointless, since a double has approximately 16
decimal digits of precision, with long double giving around 34...
Alternately look into NSNumberFormatter for more formatting options
than you can shake a significant digit at.
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
_______________________________________________
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