![](/img/trans.png)
[英]How to convert a String containing Scientific Notation to correct Javascript number format
[英]How do I format a number in scientific notation to show less digits in Javascript?
例如,我有一個數字1.3685999999999998e + 35,但我只想顯示1.368e + 35。 我嘗試固定和精確,但沒有任何效果。
您需要使用Number.prototype.toExponential
:
var x = 11827361827361872361263812631827361823618723; console.log(x.toExponential(2)); console.log(x.toExponential(3)); console.log(x.toExponential(10));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.