// Float arithmetic in a loop: a running sum, three million times. public class Floats { public static void main(String[] args) { double x = 0, acc = 0; for (int i = 0; i <= 3000000; i++) { acc += x * 2.0; x += 0.5; } System.out.println(String.format("%.1f", acc)); } }