Skip to content

Round

Rounds the provided <number> with an optional [precision] and [rounding_mode].

Placeholder Patterns

  • %formatter_number_round_<number>%
  • %formatter_number_round_[precision]:[rounding_mode]_<number>%

Options

precision

Type Required Conditions Default
Number No 0 ≤ x Config Option rounding.precision

How many digits after the decimal point should be displayed.

rounding_mode

Type Required Conditions Default
String No Config Option rounding.mode

What Rounding mode should be used.

Available modes
  • up
    Rounds away from zero. Always increases the digit prior to a non-zero discarded fraction.
    Examples:

    • -1.5 -> -2
    • -1.1 -> -2
    • -1.0 -> -1
    • 1.0 -> 1
    • 1.1 -> 2
    • 1.5 -> 2
  • down
    Rounds towards zero. Always decreases the digit prior to a non-zero discarded fraction.
    Examples:

    • -1.5 -> -1
    • -1.1 -> -1
    • -1.0 -> -1
    • 1.0 -> 1
    • 1.1 -> 1
    • 1.5 -> 1
  • ceiling
    Rounds towards positive infinity. Always rounds up if number is positive, otherwise rounds down.
    Examples:

    • -1.5 -> -1
    • -1.1 -> -1
    • -1.0 -> -1
    • 1.0 -> 1
    • 1.1 -> 2
    • 1.5 -> 2
  • floor
    Rounds towards negative infinity. Always rounds down if number is positive, otherwise rounds up.
    Examples:

    • -1.5 -> -2
    • -1.1 -> -2
    • -1.0 -> -1
    • 1.0 -> 1
    • 1.1 -> 1
    • 1.5 -> 1
  • half-up
    Rounds to nearest neighbour unless both neighbours are equidistant in which case it rounds up. This is what you're commonly teached in school.
    Examples:

    • -1.5 -> -2
    • -1.1 -> -1
    • -1.0 -> -1
    • 1.0 -> 1
    • 1.1 -> 1
    • 1.5 -> 2
  • half-down
    Rounds to nearest neighbour unless both neighbours are equidistant in which case it rounds down.
    Examples:

    • -1.5 -> -1
    • -1.1 -> -1
    • -1.0 -> -1
    • 1.0 -> 1
    • 1.1 -> 1
    • 1.5 -> 1
  • half-even
    Rounds to nearest neighbour unless both neighbours are equidistant in which case it rounds to nearest even neighbour (Up if digit to the left is odd, else down).
    Examples:

    • -1.5 -> -2
    • -1.1 -> -1
    • -1.0 -> -1
    • 1.0 -> 1
    • 1.1 -> 1
    • 1.5 -> 2

number

Type Required Conditions Default
Number Yes

The number that should be rounded.

Examples

/papi parse me %formatter_number_round_1.5%             -> 2     # Default is half-up
/papi parse me %formatter_number_round_3:_1.5%          -> 2.000 # Default is half-up
/papi parse me %formatter_number_round_:half-down_1.5%  -> 1
/papi parse me %formatter_number_round_3:half-down_1.5% -> 1.000

Last update: 22. March 2025 ()