ceil()
ceil(
n,precision?):number
Computes number rounded up to precision.
DEPRECATED
Use Math.ceil() directly instead.
Parametersβ
n: numberβ
The number to round up.
precision?: number = 0β
The precision to round up to. Defaults to 0.
Returns: numberβ
The rounded up number.
See Alsoβ
Sinceβ
2.0.0
Also known asβ
ceil (Lodash, es-toolkit) Β· β (Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)
Exampleβ
// β Deprecated approach
ceil(4.006); // => 5
ceil(6.004, 2); // => 6.01
ceil(6040, -2); // => 6100
// β
Recommended approach
Math.ceil(4.006); // => 5
Math.ceil(6.004 * 100) / 100; // => 6.01
Math.ceil(6040 / 100) * 100; // => 6100
How it works?β
Rounds number up to specified precision.
Deprecated: Use Math.ceil() directly.
Native Equivalentβ
// β ceil(value)
// β
Math.ceil(value)
Use Casesβ
Round up πβ
Round number up to nearest integer.
Math.ceil(4.1); // 5
Math.ceil(-4.9); // -4
Calculate pagesβ
Calculate total pages needed.
const totalPages = Math.ceil(items.length / pageSize);