Every line of 'javascript round to 1 decimal' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
11 function roundOne(decimalNumber) { 12 return roundTo(decimalNumber, 1); 13 }
118 export function round1(num: number) { 119 if (+num.toPrecision(4) === (num | 0)) return num; 120 else return num.toPrecision(4); 121 }
59 function round(value, decimals) { 60 return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals); 61 }
1 export function round(value: any, decimals: any) { 2 if (!decimals) decimals = 0; 3 return Number(Math.round(Number(value + 'e' + decimals)) + 'e-' + decimals); 4 }
157 static round(value, decimals) { 158 return Number(`${Math.round(`${value}e${decimals}`)}e-${decimals}`) 159 }
33 round() { 34 return new _ExactMath(arguments, 'round')._rounding(); 35 }
125 static roundDecimal(number, precision) { 126 let factor = Math.pow(10, precision); 127 return Math.round(number * factor) / factor; 128 }
590 function round(num, precision) { 591 return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision); 592 }
311 function convertDecimal(value, surroundDecimalsWith) { 312 if (/^-?([0]|([1-9][0-9]*))(\.[0-9]+)?$/.test(value) == false) { 313 throw new Error("value supposed to be a decimal number but got: " + value); 314 } 315 if (surroundDecimalsWith) { 316 return { 317 value: value, 318 toJSON: function () { 319 return surroundDecimalsWith.str + value + surroundDecimalsWith.str; 320 } 321 }; 322 } 323 else { 324 return value; 325 } 326 }
135 round(amount: number, decimals: number) { 136 return +amount.toFixed(decimals); 137 }