Javascript Data Type How to - Convert a String containing Scientific Notation to number format








Question

We would like to know how to convert a String containing Scientific Notation to number format.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from w ww  .j a  va  2s.  co  m-->
document.writeln(Number("4.8749154321E7").toPrecision());

</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: