Protocol

NSDecimalNumberBehaviors

A protocol that declares three methods that control the discretionary aspects of working with decimal numbers.

Declaration

@protocol NSDecimalNumberBehaviors

Overview

The scale and roundingMode methods determine the precision of NSDecimalNumber’s return values and the way in which those values should be rounded to fit that precision. The exceptionDuringOperation:error:leftOperand:rightOperand: method determines the way in which an NSDecimalNumber object should handle different calculation errors.

For an example of a class that adopts the NSDecimalBehaviors protocol, see the specification for NSDecimalNumberHandler.

Topics

Rounding

- roundingMode

Returns the way that NSDecimalNumber's decimalNumberBy... methods round their return values.

Required.

- scale

Returns the number of digits allowed after the decimal separator.

Required.

Handling errors

- exceptionDuringOperation:error:leftOperand:rightOperand:

Specifies what an NSDecimalNumber object will do when it encounters an error.

Required.

Constants

NSRoundingMode

These constants specify rounding behaviors.

NSCalculationError

Calculation error constants used to describe an error in exceptionDuringOperation:error:leftOperand:rightOperand:.

Relationships

Conforming Types

See Also

Managing Behavior

defaultBehavior

The way arithmetic methods round off and handle error conditions.

NSDecimalNumberHandler

A class that adopts the decimal number behaviors protocol.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software