RoundingModeType
Specifies a rounding mode used in Decimal operations, as well as DecimalFormatOptions and CurrencyFormatOptions.
'ceiling' | 'floor' | 'down' | 'up' | 'half-even' | 'half-down' | 'half-up'
Values
'ceiling'
- Round towards positive infinity
'floor'
- Round towards negative infinity
'down'
- Round towards zero
'up'
- Round away from zero
'half-even'
- If digit = 5 and digit to left is odd, round up; if even round down
'half-down'
- If digit > 5 round up; otherwise round down
'half-up'
- If digit >= 5 round up; otherwise round down
Rounding mode effect
# | ceiling | floor | down | up | half-even | half-down | half-up | # | ||
---|---|---|---|---|---|---|---|---|---|---|
-2.0 | -2 | -2 | -2 | -2 | -2 | -2 | -2 | -2.0 | ||
-1.9 | -1 | -2 | -1 | -2 | -2 | -2 | -2 | -1.9 | ||
-1.8 | -1 | -2 | -1 | -2 | -2 | -2 | -2 | -1.8 | ||
-1.7 | -1 | -2 | -1 | -2 | -2 | -2 | -2 | -1.7 | ||
-1.6 | -1 | -2 | -1 | -2 | -2 | -2 | -2 | -1.6 | ||
-1.5 | -1 | -2 | -1 | -2 | -2 | -1 | -2 | -1.5 | ||
-1.4 | -1 | -2 | -1 | -2 | -1 | -1 | -1 | -1.4 | ||
-1.3 | -1 | -2 | -1 | -2 | -1 | -1 | -1 | -1.3 | ||
-1.2 | -1 | -2 | -1 | -2 | -1 | -1 | -1 | -1.2 | ||
-1.1 | -1 | -2 | -1 | -2 | -1 | -1 | -1 | -1.1 | ||
-1.0 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1.0 | ||
-0.9 | 0 | -1 | 0 | -1 | -1 | -1 | -1 | -0.9 | ||
-0.8 | 0 | -1 | 0 | -1 | -1 | -1 | -1 | -0.8 | ||
-0.7 | 0 | -1 | 0 | -1 | -1 | -1 | -1 | -0.7 | ||
-0.6 | 0 | -1 | 0 | -1 | -1 | -1 | -1 | -0.6 | ||
-0.5 | 0 | -1 | 0 | -1 | 0 | 0 | -1 | -0.5 | ||
-0.4 | 0 | -1 | 0 | -1 | 0 | 0 | 0 |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