Contents

NSDecimalNumber

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

Declaration

class NSDecimalNumber

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.

Topics

Creating a Decimal Number

Initializing a Decimal Number

Performing Arithmetic

Rounding Off

Managing Behavior

Accessing the Value

Comparing Decimal Numbers

Getting Maximum and Minimum Possible Values

Recognizing Exceptions