Every line of 'javascript round to two decimals' 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 }
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 }
277 function round_decimals(original_number, decimals) { 278 var result1 = original_number * Math.pow(10, decimals) 279 var result2 = Math.round(result1) 280 var result3 = result2 / Math.pow(10, decimals) 281 return pad_with_zeros(result3, decimals) 282 }
182 function round(value, decimals) { 183 return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals).toFixed(decimals); 184 }
1694 function precisionRound(number, precision) { 1695 var factor = Math.pow(10, precision); 1696 return Math.round(number * factor) / factor; 1697 }
456 function roundPrecision (x, d, places = 2) { 457 return (Math.floor(x * d) / d).toFixed(places); 458 }
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 }
590 function round(num, precision) { 591 return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision); 592 }