public class doublePrecision { public static void main(String[] args) { double total = 0; total += 5.6; total += 5.8; System.out
Why not use the round() method from Math class?
// The number of 0s determines how many digits you want after the floating point // (here one digit) total = (double)Math.round(total * 10) / 10; System.out.println(total); // prints 11.4