exprv4:reference:functions:rounding_and_centering




Rounding and Centering Functions

These functions round numbers and apply center/dead-zone transforms.


ceil(x)

Rounds `x` up to the next integer.

Argument Type Description
`x` number Input value.

Returns: number.

Example:

ceil(3.1);        // 4

center(x, min)

Applies a simple dead zone.

Argument Type Description
`x` number Input value.
`min` number Dead-zone magnitude.

Returns: `0` when absolute `x` is smaller than `min`; otherwise returns `x`.

Example:

center(0.02, 0.05);   // 0
center(0.10, 0.05);   // 0.10

centerex(x, min, max, center)

Applies an advanced centering transform with dead-zone and scaling behavior.

Argument Type Description
`x` number Input value.
`min` number Dead-zone magnitude. Negative values are treated as zero.
`max` number Maximum magnitude used for scaling.
`center` number Center-shaping value used by the scaling curve.

Returns: number.

Example:

centerex(0.25, 0.05, 1.0, 0.5);

floor(x)

Rounds `x` down to the previous integer.

Argument Type Description
`x` number Input value.

Returns: number.

Example:

floor(3.9);       // 3

round(x)

Rounds `x` to the nearest integer.

Argument Type Description
`x` number Input value.

Returns: number.

Example:

round(3.6);       // 4

round(x, decimals)

Rounds `x` to a requested number of decimal places.

Argument Type Description
`x` number Input value.
`decimals` number Decimal places. Negative values round to powers of ten.

Returns: number.

Example:

round(12.345, 2);     // 12.35
round(1234, -2);      // 1200

roundup(x)

Rounds `x` away from zero.

Argument Type Description
`x` number Input value.

Returns: number.

Example:

roundup(3.1);     // 4
roundup(-3.1);    // -4

trunc(x)

Removes the fractional part of `x`.

Argument Type Description
`x` number Input value.

Returns: number.

Example:

trunc(3.9);       // 3
trunc(-3.9);      // -3

Previous: Trigonometric

Next: Strings

exprv4/reference/functions/rounding_and_centering.txt · Last modified: by 127.0.0.1

Page Tools