Every line of 'mdn tofixed' 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.
62 function toFixed(number, fractionDigits) { 63 return parseFloat(Number(number).toFixed(fractionDigits)); 64 }
161 function toFixed(a) { 162 if(a) { 163 return a.toFixed(2); 164 } 165 }
80 function toFixedDecimalString(num) { 81 return num.toFixed(6); 82 }
45 function strToFixed(str, dig) { 46 if(dig == undefined) { 47 dig = 5; 48 } 49 return str.replace(/(\d+\.\d+)/g, function(match) { 50 return parseFloat(match).toFixed(dig); 51 }); 52 }
86 function formatNumber(x) { 87 return x.toFixed(2); 88 }
32 function toFixed(val, e) { 33 return parseFloat(val.toFixed(e), 10); 34 }
118 export function round1(num: number) { 119 if (+num.toPrecision(4) === (num | 0)) return num; 120 else return num.toPrecision(4); 121 }
98 setPrecision(num: number, precision: number): string { 99 return num.toFixed(precision); 100 }
5 export function round( 6 n: number, 7 precision: number = defaultPrecision, 8 ): number { 9 return +n.toFixed(precision) 10 }
81 function formatNumber(n) { 82 return (+n.toFixed(2)).toString().replace(/(\d)(?=(\d{3})+(?:\.|$))/g, '$1,'); 83 };