@writetome51/get-cautiously-rounded
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

getCautiouslyRounded(number): number

This function avoids cumulative rounding errors only by changing rounding rules in
one area -- when the fraction part of number is .5

Examples

getCautiouslyRounded(2.5); // -->  2

getCautiouslyRounded(3.5); // -->  4

getCautiouslyRounded(-2.5); // -->  -2

getCautiouslyRounded(-3.5); // -->  -4

// In all other cases, it rounds the normal way you expect.

getCautiouslyRounded(2.7); // -->  3

getCautiouslyRounded(-2.7); // -->  -3

getCautiouslyRounded(3.2); // -->  3

Installation

npm i @writetome51/get-cautiously-rounded

Loading

import { getCautiouslyRounded }  from '@writetome51/get-cautiously-rounded';

Dependencies (6)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @writetome51/get-cautiously-rounded

    Weekly Downloads

    0

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    4.08 kB

    Total Files

    5

    Last publish

    Collaborators

    • writetome51