npm.io
3.0.1 • Published 5 years ago

@writetome51/get-rounded-up-down

Licence
MIT
Version
3.0.1
Deps
5
Size
4 kB
Vulns
0
Weekly
0

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

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

Keywords