mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-26 17:34:35 +03:00
34fcd212fa
* feat(compat): implement ceil/floor/round * Simplify --------- Co-authored-by: Sojin Park <raon0211@toss.im>
1017 B
1017 B
floor
::: info
This function is only available in es-toolkit/compat
for compatibility reasons. It either has alternative native JavaScript APIs or isn’t fully optimized yet.
When imported from es-toolkit/compat
, it behaves exactly like lodash and provides the same functionalities, as detailed here.
:::
Computes number rounded down to precision.
This function takes a number and an optional precision value, and returns the number rounded down to the specified number of decimal places.
Signature
function floor(number: number | string, precision: number | string = 0): number;
Parameters
number
(number | string
): The number to round down.precision
(number | string
, Optional): The precision to round down to, defaults to0
.
Returns
(number
): The rounded down number.
Example
import { floor } from 'es-toolkit/compat';
floor(4.006); // => 4
floor(0.046, 2); // => 0.04
floor(4060, -2); // => 4000