Protocol: NSDecimalNumberBehaviors
Overview
The NSDecimalBehaviors protocol declares three methods that control the discretionary aspects of working with NSDecimalNumber objects.Specifies what an NSDecimalNumber object will do when it encounters an error. (required)Returns the way that NSDecimalNumber's decimalNumberBy... methods round their return values. (required)Returns the number of digits allowed after the decimal separator. (required)These constants specify rounding behaviors.Calculation error constants used to describe an error in exceptionDuringOperation:error:leftOperand:rightOperand:.
Instance Method Summary (collapse)

 exceptionDuringOperation:error:leftOperand:rightOperand:
Specifies what an NSDecimalNumber object will do when it encounters an error.

 roundingMode
Returns the way that NSDecimalNumber's decimalNumberBy...

 scale
Returns the number of digits allowed after the decimal separator.
Instance Method Details
 (NSDecimalNumber) exceptionDuringOperation(method, error:error, leftOperand:leftOperand, rightOperand:rightOperand)
Specifies what an NSDecimalNumber object will do when it encounters an error. (required)
There are four possible values for error, described in NSCalculationError. The first three have to do with limits on the ability of NSDecimalNumber to represent decimal numbers. An NSDecimalNumber object can represent any number that can be expressed as mantissa x 10^exponent, where mantissa is a decimal integer up to 38 digits long, and exponent is between –256 and 256. The fourth results from the caller trying to divide by 0. In implementing exceptionDuringOperation:error:leftOperand:rightOperand:, you can handle each of these errors in several ways: Raise an exception. For an explanation of exceptions, see Exception Programming Topics. Return nil. The calling method will return its value as though no error had occurred. If error is NSCalculationLossOfPrecision, method will return an imprecise value—that is, one constrained to 38 significant digits. If error is NSCalculationUnderflow or NSCalculationOverflow, method will return NSDecimalNumber’s notANumber. You shouldn’t return nil if error is NSDivideByZero. Correct the error and return a valid NSDecimalNumber object. The calling method will use this as its own return value.
 (NSRoundingMode) roundingMode
Returns the way that NSDecimalNumber's decimalNumberBy... methods round their return values. (required)
 (Integer) scale
Returns the number of digits allowed after the decimal separator. (required)
This method limits the precision of the values returned by NSDecimalNumber’s decimalNumberBy… methods. If scale returns a negative value, it affects the digits before the decimal separator as well. If scale returns NSDecimalNoScale, the number of digits is unlimited. Assuming that roundingMode returns NSRoundPlain, different values of scale have the following effects on the number 123.456:ScaleReturn ValueNSDecimalNoScale123.4562123.450123–2100