scale()
Returns the number of digits allowed after the decimal separator.
Declaration
func scale() -> Int16Return Value
The number of digits allowed after the decimal separator.
Discussion
This method limits the precision of the values returned by NSDecimalNumber’s decimalNumberBy... methods. If scale() returns a negative value, it affects the digits before the decimal separator as well. If scale() returns NSDecimalNoScale, the number of digits is unlimited.
Assuming that roundingMode() returns NSRoundPlain, different values of scale() have the following effects on the number 123.456:
Scale | Return Value |
|---|---|
| 123.456 |
2 | 123.45 |
0 | 123 |
–2 | 100 |