Enumeration

NSDecimalNumber.RoundingMode

These constants specify rounding behaviors.

Declaration

enum RoundingMode : UInt

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

case plain

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

case down

Round return values down.

case up

Round return values up.

case bankers

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

func NSDecimalCompact(UnsafeMutablePointer<Decimal>)

Compacts the decimal structure for efficiency.

typealias Decimal.RoundingMode

An alias for an enumeration that specifies possible rounding modes.

typealias Decimal.CalculationError

An alias for a type that specifies possible calculation errors.

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