Enumeration

NSRoundingMode

These constants specify rounding behaviors.

Declaration

typedef enum NSRoundingMode : NSUInteger {
    ...
} NSRoundingMode;

Overview

The rounding mode matters only if the scale method sets a limit on the precision of NSDecimalNumber return values. It has no effect if scale returns NSDecimalNoScale. Assuming that scale returns 1, the rounding mode has the following effects on various original values:

Original Value

NSRoundPlain

NSRoundDown & NS RoundUp

NSRoundBankers

1.24

1.2

1.2 & 1.3

1.2

1.26

1.3

1.2 & 1.3

1.3

1.25

1.3

1.2 & 1.3

1.2

1.35

1.4

1.3 & 1.4

1.4

–1.35

–1.4

–1.4 & -1.3

–1.4

Topics

Constants

NSRoundPlain

Round to the closest possible return value; when caught halfway between two positive numbers, round up; when caught between two negative numbers, round down.

NSRoundDown

Round return values down.

NSRoundUp

Round return values up.

NSRoundBankers

Round to the closest possible return value; when halfway between two possibilities, return the possibility whose last digit is even.

See Also

Performing Arithmetic Using References

NSDecimalCompact

Compacts the decimal structure for efficiency.

NSDecimalAdd

Adds two decimal values.

NSDecimalSubtract

Subtracts one decimal value from another.

NSDecimalDivide

Divides one decimal value by another.

NSDecimalMultiply

Multiplies two decimal numbers together.

NSDecimalMultiplyByPowerOf10

Multiplies a decimal by the specified power of 10.

NSDecimalRound

Rounds off the decimal value.

NSDecimalPower

Raises the decimal value to the specified power.

NSDecimalNormalize

Normalizes the internal format of two decimal numbers to simplify later operations.

NSCalculationError

Calculation error constants used to describe an error in exceptionDuringOperation:error:leftOperand:rightOperand:.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software