<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSDecimalNumberBehaviors",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSDecimalNumberBehaviors"
  },
  "title" : "NSDecimalNumberBehaviors"
}
-->

# NSDecimalNumberBehaviors

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

```
protocol NSDecimalNumberBehaviors
```

## Overview

The [`scale()`](/documentation/Foundation/NSDecimalNumberBehaviors/scale()) and [`roundingMode()`](/documentation/Foundation/NSDecimalNumberBehaviors/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:)`](/documentation/Foundation/NSDecimalNumberBehaviors/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`](/documentation/Foundation/NSDecimalNumberHandler).

## Topics

### Rounding

[`-  roundingMode`](/documentation/Foundation/NSDecimalNumberBehaviors/roundingMode())

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

[`-  scale`](/documentation/Foundation/NSDecimalNumberBehaviors/scale())

Returns the number of digits allowed after the decimal separator.

### Handling errors

[`-  exceptionDuringOperation:error:leftOperand:rightOperand:`](/documentation/Foundation/NSDecimalNumberBehaviors/exceptionDuringOperation(_:error:leftOperand:rightOperand:))

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

### Constants

[`RoundingMode`](/documentation/Foundation/NSDecimalNumber/RoundingMode)

These constants specify rounding behaviors.

[`CalculationError`](/documentation/Foundation/NSDecimalNumber/CalculationError)

Calculation error constants used to describe an error in [`exceptionDuringOperation(_:error:leftOperand:rightOperand:)`](/documentation/Foundation/NSDecimalNumberBehaviors/exceptionDuringOperation(_:error:leftOperand:rightOperand:)).

## Relationships

### Conforming Types

[`NSDecimalNumberHandler`](/documentation/Foundation/NSDecimalNumberHandler)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)