double (Java)
double is the Java primitive type for numbers with a decimal point, such as 3.14 or -0.5. It stores a 64-bit floating-point value and is the default choice for decimal numbers in Java.
Java
Because doubles are stored in binary, some decimals can't be represented exactly, which can cause tiny rounding errors. For money and exact decimals, use the BigDecimal class instead.
Dividing two doubles keeps the decimal part, unlike integer division: 7.0 / 2 gives 3.5.
Examples
Java
double price = 19.99;
System.out.println(price + 0.01);
System.out.println(7.0 / 2);Output:
20.0
3.5