Skip to content

writetome51/get-cautiously-rounded

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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';

About

Avoids rounding errors in very large data sets

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published