2.0.0 • Published 8 years ago

significant-rounding v2.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

significant-rounding

function(number
       , minTotalLength=9          //Including comma
       , minDecimals=2             //How many decimals when number has no decimal places
       , trailingZeros = false     //Trailing zeros when abs(number) is less than 1
       , significantRounding=null)

If absolute number is greater than zero (num > 0) then minDecimals and normal formatting is used.

rounding(123.123456, 5);            //Outputs 123.12
rounding(123.100000, 5);            //Outputs 123.10
rounding(123.100000, 5, 4, true);   //Outputs 123.1000
rounding(1234.12, 2, 2, true, 3));  //Outputs 1230.00

If absolute number is less than zero (num < 0) then maxDecimals and significant rounding is used.

rounding(0.0000123456789, 5);       //Outputs 0.000012346
rounding(0.0123456789, 5);          //Outputs 0.012346
rounding(0.012, 5);                 //Outputs 0.012
rounding(0.012, 5, true);           //Outputs 0.012000
rounding(0.0123001, 5);             //Outputs 0.01230
2.0.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago