LoginSignup
0
0

More than 3 years have passed since last update.

Javaのdouble型

Posted at

double型

double型は小数点以下を持つ数になります。
int型は整数で、1とか3とかです。
対してdouble型は1.2とか3.5とかの少数点以下に定義します。

小数同士の計算

【例】

Main.java
class Main {
  public static void main(String[] args) {
    double number1 = 8.9;
    double number2 = 1.2;
    System.out.println(number1 + number2);
    System.out.println(number1 - number2);

  }
}

上記の例だと結果は11.1と7.7になります。

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