Strange error on float multiplication

Hi apparently, float multiplication have some problem with some value... just try this:

void setup() {
  for (int i = 0; i < 100; i++) {
    println(i*.1);
  }
}

the result is

0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.90000004
1.0
1.1
1.2
1.3000001
1.4
1.5
1.6
1.7
1.8000001
1.9
2.0
2.1000001
2.2
2.3
2.4
2.5
2.6000001
2.7
2.8
2.9
3.0
3.1000001
3.2
3.3
3.4
3.5
3.6000001
3.7
3.8
3.9
4.0
4.1
4.2000003
4.3
4.4
4.5
4.6
4.7000003
4.8
4.9

this is amazing !!!!!!

Tagged:

Answers

Sign In or Register to comment.