floor

math

Computes number rounded down to precision.

Signature

floor(number: number, precision?: number): number

Parameters

NameTypeDescription
numbernumberThe number to round down
precision?numberThe precision to round down toDefault: 0

Returns

number - Returns the rounded down number

Examples

Round to integer

import { floor } from 'dashlite'

const result = floor(4.006)
console.log(result)

Output:

4

Round with precision

import { floor } from 'dashlite'

const result = floor(0.046, 2)
console.log(result)

Output:

0.04

Negative precision

import { floor } from 'dashlite'

const result = floor(4060, -2)
console.log(result)

Output:

4000

Available since version 1.0.0