Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Number.prototype.toExponential()

概要

Number オブジェクトを指数表記で表した文字列を返します。

構文

number.toExponential( fractionDigits )

引数

fractionDigits
小数点の後の桁数を示す整数。デフォルトはその数を表すのに必要な数の桁。

戻り値

Number オブジェクトを、指数表記(小数点前は 1 桁、小数点の後は fractionDigits によって指定された桁で切り捨て)で表した文字列。 引数 fractionDigits が省略された場合、小数点の後の桁数は、その値を特定するのに必要な桁数になります。

toExponential メソッドを 1 つの数値リテラル、または、指数も小数点もない数値リテラルに対して使用する場合、ドットが小数点として解釈されることを防ぐために、メソッド呼び出しに先立つドットの前に空白を置いてください。

引数 fractionDigits で指定された桁よりも多くの桁を持っている数の場合、その数は、fractionDigits の桁で表すことができる最も近い数で表されます。toFixed メソッドの説明における概数表現の説明を参照してください。それは、 toExponential メソッドにも適用されます。

var num=77.1234;

alert("num.toExponential() is " + num.toExponential()); // 7.71234e+1 を表示します。

alert("num.toExponential(4) is " + num.toExponential(4)); // 7.7123e+1 を表示します。

alert("num.toExponential(2) is " + num.toExponential(2)); // 7.71e+1 を表示します。

alert("77.1234.toExponential() is " + 77.1234.toExponential()); // 7.71234e+1 を表示します。

alert("77 .toExponential() is " + 77 .toExponential()); // 7.7e+1 を表示します。

参照

Number.toFixed, Number.toPrecision, Number.toString

ドキュメントのタグと貢献者

 このページの貢献者: teoli, ethertank, Potappo
 最終更新者: teoli,