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.
Behaves same as Math.floor()
.
Behaves same as Math.ceil()
.
For all 3 functions, num
must be a finite number of type 'number'.
npm i @writetome51/get-rounded-up-down
import { getRounded, getRoundedDown, getRoundedUp }
from '@writetome51/get-rounded-up-down';