0
0

Javaで「浮動小数点数リテラル」の動作を確認してみた

Posted at

概要

Javaで「浮動小数点数リテラル」の動作を確認してみました。
以下のページを参考にしました。

実装

以下のファイルを作成しました。

JSample7_1.java
class JSample7_1{
  public static void main(String[] args){
    System.out.println(18.225);
    System.out.println(5.23e3);
    System.out.println(1.816e10);
    System.out.println(7.5e-2);
    System.out.println(2.712e-6);
    System.out.println(3.52 + 17.4);
  }
}

以下のコマンドを実行しました。

$ javac -encoding UTF-8 JSample7_1.java
$ java JSample7_1 
18.225
5230.0
1.816E10
0.075
2.712E-6
20.919999999999998

まとめ

何かの役に立てばと。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0