#round #npm #numbers #round-to #ceil #floor

round2rs

Based on round-to NPM Crate

3 releases

0.1.3 Mar 15, 2024
0.1.1 Mar 15, 2024
0.1.0 Mar 15, 2024

#5 in #round

Download history 240/week @ 2024-03-11 51/week @ 2024-03-18 26/week @ 2024-04-01

317 downloads per month

MIT license

4KB

round2rs

Round a number to a specific number of decimal places: 1.2341.2 supports negative numbers as well

Install

cargo add round-to

Usage

use round_to::RoundTo;

RoundTo::round_to(1.234, 2);
//=> 1.23

RoundTo::round_to_ceil(1.234, 2);
//=> 1.24

RoundTo::round_to_floor(1.234, 2);
//=> 1.23

API

number

Type: number

The number to adjust.

precision

Type: number (Integer or infinity)

The number of decimal places.

No runtime deps