These functions round numbers and apply center/dead-zone transforms.
Rounds `x` up to the next integer.
| Argument | Type | Description |
|---|---|---|
| `x` | number | Input value. |
Returns: number.
Example:
ceil(3.1); // 4
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
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);
Rounds `x` down to the previous integer.
| Argument | Type | Description |
|---|---|---|
| `x` | number | Input value. |
Returns: number.
Example:
floor(3.9); // 3
Rounds `x` to the nearest integer.
| Argument | Type | Description |
|---|---|---|
| `x` | number | Input value. |
Returns: number.
Example:
round(3.6); // 4
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
Rounds `x` away from zero.
| Argument | Type | Description |
|---|---|---|
| `x` | number | Input value. |
Returns: number.
Example:
roundup(3.1); // 4 roundup(-3.1); // -4
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