Skip to main content

Function modifiers

decimals

Commentary​

added in 0.3.21

Limit the number of decimals on a number using the half up rounding algorithm.

If decimals is set to zero, generates integers by always rounding down (e.g. chopping off the trailing decimal suffix).


Examples​

Rounding to two decimals​

Use 2 decimals to drop the remaining decimal places.

{
"_gen": "constant",
"x": 10.12345,
"decimals": 2
}
[
10.12
]

Rounding to an integer​

Use 0 to retrieve whole integers.

{
"_gen": "constant",
"x": 42.793853,
"decimals": 0
}
[
42
]

Specification​

JSON schema​

{
"type": "integer",
"minimum": 0
}