Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 855 Bytes

README.md

File metadata and controls

18 lines (13 loc) · 855 Bytes

significant-rounding

function(number, decimals, trailingZeros = false, minDecimals = 2, significantRounding=false)

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, true, 4);   //Outputs 123.1000
rounding(1234.12, 2, true, 2, true) //Outputs 120.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, true);       //Outputs 0.012300