Skip to main content
Version: 1.2.10

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.90-1 0-1 -1-1-1-0.9
-0.80-1 0-1 -1-1-1-0.8
-0.70-1 0-1 -1-1-1-0.7
-0.60-1 0-1 -1-1-1-0.6
-0.50-1 0-1 00-1-0.5
-0.40-1 0-1 000-0.4
-0.30-1 0-1 000-0.3
-0.20-1 0-1 000-0.2
-0.10-1 0-1 000-0.1
000 00 0000
0.110 01 0000.1
0.210 01 0000.2
0.310 01 0000.3
0.410 01 0000.4
0.510 01 0010.5
0.610 01 1110.6
0.710 01 1110.7
0.810 01 1110.8
0.910 01 1110.9
1.011 11 1111.0
1.121 12 1111.1
1.221 12 1111.2
1.321 12 1111.3
1.421 12 1111.4
1.521 12 2121.5
1.621 12 2221.6
1.721 12 2221.7
1.821 12 2221.8
1.921 12 2221.9
2.022 22 2222.0

References