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

https://github.com/writetome51/get-rounded-up-down

3 functions for rounding floats to integers
https://github.com/writetome51/get-rounded-up-down

ceil floor javascript javascript-library math numbers round rounding typescript

Last synced: 8 months ago
JSON representation

3 functions for rounding floats to integers

Awesome Lists containing this project

README

          

# getRounded(num): number

Avoids cumulative rounding errors only by changing rounding rules when
the fraction part of `num` is `.5` :


  • If num's whole number is even, num is rounded toward zero.

  • If num's whole number is odd, num is rounded away from zero.

# getRoundedDown(num): number

Behaves same as `Math.floor()` .

# getRoundedUp(num): number

Behaves same as `Math.ceil()` .

For all 3 functions, `num` must be a finite number of type 'number'.

## Installation

`npm i @writetome51/get-rounded-up-down`

## Loading
```js
import { getRounded, getRoundedDown, getRoundedUp }
from '@writetome51/get-rounded-up-down';
```