如何将包含科学记数法的字符串转换为正确的Javascript数字格式 [英] How to convert a String containing Scientific Notation to correct Javascript number format
本文介绍了如何将包含科学记数法的字符串转换为正确的Javascript数字格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
将它作为字符串传递给Number函数。
数字(4.874915326E7)//返回48749153.26
I have a String e.g: "4.874915326E7". What is the best way to convert it to a javascript number format? (int or float)? if I try parseInt(), the E at the end is ignored.
解决方案
Pass it as a string to the Number function.
Number("4.874915326E7") //returns 48749153.26
这篇关于如何将包含科学记数法的字符串转换为正确的Javascript数字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文