number.toExponential()メソッドは、Numberオブジェクトの数値を指数表記にした文字列を返すメソッド。
構文
number.toExponential()
戻り値
指数表記にした文字列。
サンプル
<script type="text/javascript">
var $numberObject = new Number( 12345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>4</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 1234.5 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>3</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 123.45 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>2</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 12.345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>1</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 1.2345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>0</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 0.12345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>-1</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 0.012345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>-2</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 0.0012345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>-3</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
</script>
var $numberObject = new Number( 12345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>4</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 1234.5 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>3</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 123.45 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>2</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 12.345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>1</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 1.2345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>0</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 0.12345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>-1</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 0.012345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>-2</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
var $numberObject = new Number( 0.0012345 );
document.write( $numberObject );
document.write( ' = 1.2345x10<sup>-3</sup> = ' );
document.write( $numberObject.toExponential() + '<br />' );
</script>
↓↓↓出力結果↓↓↓