O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSDecimalNumberHandler — Mac OS X 10.0

Synopsis

This class is used to customize the behavior of NSDecimalNumber-based arithmetic without having to subclass. In particular, NSDecimalNumberHandler allows clients to specify how NSDecimalNumber objects should handle rounding and errors.

image with no caption

@interface NSDecimalNumberHandler : NSObject <NSCoding, NSDecimalNumberBehaviors>
                                  // Initializers
   - (id)initWithRoundingMode:(NSRoundingMode)roundingMode 
                                 scale:(short)scale 
                                 raiseOnExactness:(BOOL)exact
                                 raiseOnOverflow:(BOOL)overflow 
                                 raiseOnUnderflow:(BOOL)underflow 
                                 raiseOnDivideByZero:(BOOL)divideByZero;
                                  // Class Methods
   + (id)decimalNumberHandlerWithRoundingMode:(NSRoundingMode)roundingMode
                                 scale:(short)scale 
                                 raiseOnExactness:(BOOL)exact 
                                 raiseOnOverflow:(BOOL)overflow
                                 raiseOnUnderflow:(BOOL)underflow 
                                 raiseOnDivideByZero:(BOOL)divideByZero;
   + (id)defaultDecimalNumberHandler;
                                  // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
                                  // Methods Implementing NSDecimalNumberBehaviors
   - (NSRoundingMode)roundingMode;
   - (short)scale;
   - (NSDecimalNumber *)exceptionDuringOperation:(SEL)operation 
                                 error:(NSCalculationError)error
                                 leftOperand:(NSDecimalNumber *)leftOperand 
                                 rightOperand:(NSDecimalNumber *)rightOperand;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required