NSDecimalNumber.RoundingMode
These constants specify rounding behaviors.
Declaration
enum RoundingModeOverview
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
NSDecimalNumber.RoundingMode.plainNSDecimalNumber.RoundingMode.downNSDecimalNumber.RoundingMode.upNSDecimalNumber.RoundingMode.bankers
Initializers
See Also
Performing arithmetic using references
NSDecimalCompact(_:)NSDecimalAdd(_:_:_:_:)NSDecimalSubtract(_:_:_:_:)NSDecimalDivide(_:_:_:_:)NSDecimalMultiply(_:_:_:_:)NSDecimalMultiplyByPowerOf10(_:_:_:_:)NSDecimalRound(_:_:_:_:)NSDecimalPower(_:_:_:_:)NSDecimalNormalize(_:_:_:)Decimal.RoundingModeDecimal.CalculationErrorNSDecimalNumber.CalculationError