Demonstrating the toPrecision() method : toPrecision « Number Data Type « JavaScript Tutorial






<html>
<head>
<title>Demonstrating the toPrecision() method</title>
<script type="text/javascript" language="javascript">
<!-- //
function DisplayPrecision(){
    number = new Number(1200000000003);
    for (var i=1; i<8; i++){
        document.write(number.toPrecision(i));
    }
}
// -->
</script>
</head>
<body onload="DisplayPrecision()">
<P>This listing demonstrates the use of the toPrecision() method.</p><br />
</body>
</html>








5.21.toPrecision
5.21.1.Demonstrating the toPrecision() method