Utils.roundToNearest()
Return the number given as first parameter rounded to the nearest multiple of the number given as second parameter
Parameters
Name | Type | Description | |
---|---|---|---|
1 | x | number | |
2 | nearest | number |
Return value
number
the result
Usage
import {Utils} from '@lcluber/type6js';
let number = 2.563995;
let roundToNearest = Utils.roundToNearest(number, 0.5);
console.log(roundToNearest); //(2.5)