---
title: NSDecimalNumber
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsdecimalnumber
---

# NSDecimalNumber

An object for representing and performing arithmetic on base-10 numbers.

## Declaration

```swift
class NSDecimalNumber
```

## Overview

Overview In Swift, this object bridges to Decimal; use NSDecimalNumber when you need reference semantics or other Foundation-specific behavior. NSDecimalNumber, an immutable subclass of NSNumber, provides an object-oriented wrapper for doing base-10 arithmetic. An instance 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 an integer from –128 through 127. important: The Swift overlay to the Foundation framework provides the Decimal structure, which bridges to the NSDecimalNumber class. For more information about value types, see Working with Foundation Types.

## Topics

### Creating a Decimal Number

- [one](foundation/nsdecimalnumber/one.md)
- [zero](foundation/nsdecimalnumber/zero.md)
- [notANumber](foundation/nsdecimalnumber/notanumber.md)

### Initializing a Decimal Number

- [init(decimal:)](foundation/nsdecimalnumber/init(decimal:).md)
- [init(mantissa:exponent:isNegative:)](foundation/nsdecimalnumber/init(mantissa:exponent:isnegative:).md)
- [init(string:)](foundation/nsdecimalnumber/init(string:).md)
- [init(string:locale:)](foundation/nsdecimalnumber/init(string:locale:).md)

### Performing Arithmetic

- [adding(_:)](foundation/nsdecimalnumber/adding(_:).md)
- [subtracting(_:)](foundation/nsdecimalnumber/subtracting(_:).md)
- [multiplying(by:)](foundation/nsdecimalnumber/multiplying(by:).md)
- [dividing(by:)](foundation/nsdecimalnumber/dividing(by:).md)
- [raising(toPower:)](foundation/nsdecimalnumber/raising(topower:).md)
- [multiplying(byPowerOf10:)](foundation/nsdecimalnumber/multiplying(bypowerof10:).md)
- [adding(_:withBehavior:)](foundation/nsdecimalnumber/adding(_:withbehavior:).md)
- [subtracting(_:withBehavior:)](foundation/nsdecimalnumber/subtracting(_:withbehavior:).md)
- [multiplying(by:withBehavior:)](foundation/nsdecimalnumber/multiplying(by:withbehavior:).md)
- [dividing(by:withBehavior:)](foundation/nsdecimalnumber/dividing(by:withbehavior:).md)
- [raising(toPower:withBehavior:)](foundation/nsdecimalnumber/raising(topower:withbehavior:).md)
- [multiplying(byPowerOf10:withBehavior:)](foundation/nsdecimalnumber/multiplying(bypowerof10:withbehavior:).md)

### Rounding Off

- [rounding(accordingToBehavior:)](foundation/nsdecimalnumber/rounding(accordingtobehavior:).md)

### Managing Behavior

- [defaultBehavior](foundation/nsdecimalnumber/defaultbehavior.md)
- [NSDecimalNumberBehaviors](foundation/nsdecimalnumberbehaviors.md)
- [NSDecimalNumberHandler](foundation/nsdecimalnumberhandler.md)

### Accessing the Value

- [decimalValue](foundation/nsdecimalnumber/decimalvalue.md)
- [doubleValue](foundation/nsdecimalnumber/doublevalue.md)
- [description(withLocale:)](foundation/nsdecimalnumber/description(withlocale:).md)
- [objCType](foundation/nsdecimalnumber/objctype.md)

### Comparing Decimal Numbers

- [compare(_:)](foundation/nsdecimalnumber/compare(_:).md)

### Getting Maximum and Minimum Possible Values

- [maximum](foundation/nsdecimalnumber/maximum.md)
- [minimum](foundation/nsdecimalnumber/minimum.md)

### Recognizing Exceptions

- [decimalNumberExactnessException](foundation/nsexceptionname/decimalnumberexactnessexception.md)
- [decimalNumberOverflowException](foundation/nsexceptionname/decimalnumberoverflowexception.md)
- [decimalNumberUnderflowException](foundation/nsexceptionname/decimalnumberunderflowexception.md)
- [decimalNumberDivideByZeroException](foundation/nsexceptionname/decimalnumberdividebyzeroexception.md)

## Relationships

### Inherits From

- [NSNumber](foundation/nsnumber.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [ExpressibleByBooleanLiteral](swift/expressiblebybooleanliteral.md)
- [ExpressibleByFloatLiteral](swift/expressiblebyfloatliteral.md)
- [ExpressibleByIntegerLiteral](swift/expressiblebyintegerliteral.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
