August 6, 2000 - Number Formatting in Netscape 6
![]() |
August 6, 2000 Number Formatting in Netscape 6 Tips: August 2000
Yehuda Shiran, Ph.D.
|
fixed and exponential.
For the fixed format, you may provide as a parameter the number of digits after the decimal point. For example, formatting the number 10.532 with 2 digits may be accomplished by the following script:
<SCRIPT LANGUAGE="JavaScript">
var a = 10.532;
alert(a.toFixed(2));
</SCRIPT>This script yields the following alert box:

exponential format, you may provide as a parameter the number of digits after the decimal point in the mantisa. For example, foramtting the number 10.532 with 5 digits may be accomplished by the following script:
<SCRIPT LANGUAGE="JavaScript">
var a = 10.532;
alert(a.toExponential(5));
</SCRIPT>The script yields the following alert box:




