<!--
{
  "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/NSDecimalNumberHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDecimalNumberHandler"
  },
  "title" : "NSDecimalNumberHandler"
}
-->

# NSDecimalNumberHandler

A class that adopts the decimal number behaviors protocol.

```
class NSDecimalNumberHandler
```

## Overview

This class allows you to set the way an [`NSDecimalNumber`](/documentation/Foundation/NSDecimalNumber) object rounds off and handles errors, without having to create a custom class.

You can use an instance of this class as an argument to any of the [`NSDecimalNumber`](/documentation/Foundation/NSDecimalNumber) methods that end with `...Behavior:`. If you don’t think you need special behavior, you probably don’t need this class—it is likely that [`NSDecimalNumber`](/documentation/Foundation/NSDecimalNumber)’s default behavior will suit your needs.

For more information, see the [`NSDecimalNumberBehaviors`](/documentation/Foundation/NSDecimalNumberBehaviors) protocol specification.

## Topics

### Creating a Decimal Number Handler

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

Returns the default instance of `NSDecimalNumberHandler`.

[`+  decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:`](/documentation/Foundation/NSDecimalNumberHandler/decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:)

Returns an `NSDecimalNumberHandler` object with customized behavior.

### Initializing a decimal number handler

[`-  initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:`](/documentation/Foundation/NSDecimalNumberHandler/init(roundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:))

Returns an `NSDecimalNumberHandler` object initialized so it behaves as specified by the method’s arguments.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

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

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

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

[`Sendable`](/documentation/Swift/Sendable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)