Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1072 Netscape 2 rounding error

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.

Affects: Netscape 2.x

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>

Feedback on 'Q1072 Netscape 2 rounding error'

©2018 Martin Webb