Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sunopar/round-js

Dealing with JavaScript's numerical round problems
https://github.com/sunopar/round-js

javascript nodejs number-round number-systems

Last synced: 19 days ago
JSON representation

Dealing with JavaScript's numerical round problems

Awesome Lists containing this project

README

        

# round-js
Dealing with JavaScript's round problem

## why use round-js
when we want to round a number with float, something will go that doesn't what we expect if use `Number.toFixed`. Consider the situation below:

```
10.145.toFixed(2) --> 10.14
```
the equation will return 10.14, but what we expect is 10.15.

## how to use round-js

```
npm install --save so-round
```
in file

```
import round from 'so-round'
round(10.145,2) ---> 10.15
```

more detail can be inspect from `test/round.test.js`