tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

11 lignes · 334 octetsBrut · Historique
1// Float arithmetic in a loop: a running sum, three million times.
2public class Floats {
3 public static void main(String[] args) {
4 double x = 0, acc = 0;
5 for (int i = 0; i <= 3000000; i++) {
6 acc += x * 2.0;
7 x += 0.5;
8 }
9 System.out.println(String.format("%.1f", acc));
10 }
11}