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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/georg.seifert %40gmx.de

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to