如何将包含科学计数法的字符串转换为正确的 JavaScript 数字格式?
要转换带有科学计数法的字符串,请使用 Number 函数。将值传递给此函数。
示例
你可以尝试运行以下代码,将字符串转换为正确的数字格式 −
<!DOCTYPE html>
<html>
<body>
<script>
document.write("String with Scientific Notation converted below:<br>");
document.write(Number("7.53245683E7"));
</script>
</body>
</html>输出
String with Scientific Notation converted below: 75324568.3
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP