public static void main(String[] args) {
double test = 1;
int tick = 0;
while(tick < 10){
System.out.println(test += 1.4);
tick++;
}
}
Result:
2.4
3.8
5.199999999999999
6.6
8.0
9.4
10.8
12.200000000000001
13.600000000000001
15.000000000000002
I don't understand why It get these strange decimal numbers like 5.19 instead of 5.2 Why is this? And is there a way to just make it appear to 5.2 like my calculator does? Thanks in advance. Marten