Re: Rounding very small numbers.
Re: Rounding very small numbers.
- Subject: Re: Rounding very small numbers.
- From: Georg Seifert <email@hidden>
- Date: Thu, 11 Sep 2008 13:54:30 +0200
cant you just multiply with 10000, round it and divide 10000?
g
Am 11.09.2008 um 10:11 schrieb Ryan Ragona:
Hey all,
I've been scouring the archives, but coming up without any solution
that
seems to work in my application. Here is the issue:
I have some tiny numbers, like -0.000000116916, for example, that I
want
rounded to the 5th decimal place or so. -0.00000 is plenty precise
for my
purposes.
I attempted to do that with the following code:
NSDecimalNumberHandler* roundingBehavior = [NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode:NSRoundPlain scale:5];
NSDecimalNumber *roundFloat = [[[[NSDecimalNumber alloc]
initWithFloat:0.0000000111123]
decimalNumberByRaisingToPower:5]
decimalNumberByRoundingAccordingToBehavior:
roundingBehavior];
... but I'm getting the following warning:
"NSDecimalNumberHandler" may not respond to "decimalNumberHandler..."
... and in addition, my code crashes when I attempt to run with this
warning. XCode seems comfortable suggesting the
decimalNumberHandlerWithRoundingMode method, but it does not seem to
work.
All of the code examples I see seem to have something exactly like
this, but
it isn't at all working with my project.
Do I need to implement a protocol? I'm pretty lost. Am I going about
this
totally the wrong way? Is there a much easier way to round? I don't
really
need it stored, should I be using C methods? (How do I do that?)
Thanks!
-Ryan
_______________________________________________
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:
@gmx.de
This email sent to email@hidden
_______________________________________________
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