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
- Host: GitHub
- URL: https://github.com/writetome51/get-rounded-up-down
- Owner: writetome51
- License: mit
- Created: 2018-10-03T01:57:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T04:53:43.000Z (over 4 years ago)
- Last Synced: 2025-02-02T13:07:08.143Z (8 months ago)
- Topics: ceil, floor, javascript, javascript-library, math, numbers, round, rounding, typescript
- Language: JavaScript
- Homepage:
- Size: 55.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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';
```