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

func roundingMode() -> NSDecimalNumber.RoundingMode

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

Required.

func scale() -> Int16

Returns the number of digits allowed after the decimal separator.

Required.

Constants

enum NSDecimalNumber.RoundingMode

These constants specify rounding behaviors.

Relationships

Conforming Types

See Also

Managing Behavior

class var defaultBehavior: NSDecimalNumberBehaviors

The way arithmetic methods round off and handle error conditions.

class NSDecimalNumberHandler

A class that adopts the decimal number behaviors protocol.