You are here: irt.org | FAQ | JavaScript | Bugs | Q1072 [ previous next ]
Symptom: I have not personally seen it and the eval in the workaround will crash Netscape Navigator 2.00 (try setTimeout instead) but here it is anyway.
Workaround:
<SCRIPT> // Fixing rounding bug in Netscape 2 function roundIt(value) { var newFullAmount, newDecimals; if (value<=0.99) newFullAmount = '0'; else newFullAmount = parseInt(value); newDecimals = parseInt((value+.0008 - newFullAmount)* 100); if (eval(newDecimals) <= 9) newDecimals='0'+newDecimals; newString = newFullAmount + '.' + newDecimals; return (newString); } </SCRIPT>