Meltemi
Meltemi

Reputation: 38359

Cocoa Foundation Kit question - NSDecimalNumberBy...:withBehavior:

I'm trying to take a numeric value in a string and raise it by a power of 10. stumbled upon – decimalNumberByMultiplyingByPowerOf10:withBehavior: which looks promising but I can't for the life of me figure out how to configure/set the withBehavior argument. I think I need to set it to NSRoundDown so when raising to negative power it won't round 'up' some values below a certain number of decimal places...but how does one set/use this NSDecimalNumberBehaviors gizmo? Sure wish Apple provided some examples in their docs...

Upvotes: 1

Views: 120

Answers (1)

Matt Ball
Matt Ball

Reputation: 6618

Check out NSDecimalNumberHandler. It conforms to the NSDecimalNumberBehaviors protocol, as required by the API, and allows you to configure all the behaviors you're likely to need.

Upvotes: 1

Related Questions