Number.toFixed
指定された小数点位置に数値を丸めます。123.456の場合、toFixed(2)とすると結果は123.46となります。Macintosh版Internet Explorer 5では動作しません。Windows版Internet Explorerはバージョン5.5以降で利用することができます。
構文
数値.toFixed(小数点位置)
例文
<html> <head> <title>Number.toFixed</title> </head> <body> <script type="text/javascript"><!-- n = 123.456; val = n.toFixed(2); document.write(val); // --></script> </body> </html>
関連記事
- Number.toPrecision
- Number.toExponential
- Number.prototype
- Number.NaN
- isNaN
- Number.toString
- Number.POSITIVE_INFINITY
- Number.NEGATIVE_INFINITY
- Number.MIN_VALUE
- Number.MAX_VALUE
スポンサーリンク