Shorten¶
"Shortens" the number by dividing it through 1,000, 10,000, etc. where applicable and attaches a text at the end based on the number it divided it through.
As an example, 10000 will become 10K while 1000000 will become 1M.
Placeholder Patterns¶
%formatter_number_shorten_<number>%%formatter_number_shorten_<rounding_mode>_<number>%
Options¶
rounding_mode¶
| Type | Required | Conditions | Default |
|---|---|---|---|
| String | No | Config Option shorten.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 -> -11.0 -> 11.1 -> 21.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 -> -11.0 -> 11.1 -> 11.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 -> -11.0 -> 11.1 -> 21.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 -> -11.0 -> 11.1 -> 11.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 -> -11.0 -> 11.1 -> 11.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 -> -11.0 -> 11.1 -> 11.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 -> -11.0 -> 11.1 -> 11.5 -> 2
number¶
| Type | Required | Conditions | Default |
|---|---|---|---|
| Number | Yes |
The number that should be shortened.
Examples¶
/papi parse me %formatter_number_shorten_999% -> 999
/papi parse me %formatter_number_shorten_1000% -> 1K
/papi parse me %formatter_number_shorten_10000% -> 10K
/papi parse me %formatter_number_shorten_100000% -> 100K
/papi parse me %formatter_number_shorten_1000000% -> 1M