0

I ran a test to print the sequence 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0.

  test('excersice', () {
    for (double i = 0.0; i < 1; i += 0.1) {
      print(i);
    }
  });

and got the following output. Can someone explain why the output is not accurate?

0.0
0.1
0.2
0.30000000000000004
0.4
0.5
0.6
0.7
0.7999999999999999
0.8999999999999999
0.9999999999999999
zex_rectooor
  • 692
  • 7
  • 26

0 Answers0