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>

関連記事

スポンサーリンク

-単項演算子 負号

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る