Floating-Point Calculations : Float Point Data Type « Data Type « Java Tutorial






The four arithmetic operators: +, -, *, /.

public class MainClass {
  public static void main(String[] args) {
    double numA = 50.0E-1;   // 5.0
    double numB = 1.0E1;     // 10.0
    double averageC = 0.0;

    averageC = (numA + numB) / 2.0;
    
    System.out.println(averageC);
  }
}
7.5








2.10.Float Point Data Type
2.10.1.Floating-Point Data Types: memory and length
2.10.2.Write Floating-Point Literals with an exponent
2.10.3.Floating-Point Calculations
2.10.4.Using ++ and -- with floating-point variables
2.10.5.Applying the modulus operator, %, to floating-point values