Compare the output of the following:
>> fprintf('%0.20f\n', 0.1.*(1:10))
0.10000000000000001000
0.20000000000000001000
0.30000000000000004000
0.40000000000000002000
0.50000000000000000000
0.60000000000000009000
0.70000000000000007000
0.80000000000000004000
0.90000000000000002000
1.00000000000000000000
>> fprintf('%0.20f\n', cumsum(repmat(0.1,1,10)))
0.10000000000000001000
0.20000000000000001000
0.30000000000000004000
0.40000000000000002000
0.50000000000000000000
0.59999999999999998000
0.69999999999999996000
0.79999999999999993000
0.89999999999999991000
0.99999999999999989000
Also compare against using MATLAB's COLON operator:
>> fprintf('%0.20f\n', 0.1:0.1:1)
0.10000000000000001000
0.20000000000000001000
0.30000000000000004000
0.40000000000000002000
0.50000000000000000000
0.59999999999999998000
0.69999999999999996000
0.80000000000000004000
0.90000000000000002000
1.00000000000000000000
If you want to see the 64-bit binary representation, use:
>> format hex
>> [(0.1:0.1:1)' (0.1.*(1:10))' cumsum(repmat(0.1,10,1))]
3fb999999999999a 3fb999999999999a 3fb999999999999a
3fc999999999999a 3fc999999999999a 3fc999999999999a
3fd3333333333334 3fd3333333333334 3fd3333333333334
3fd999999999999a 3fd999999999999a 3fd999999999999a
3fe0000000000000 3fe0000000000000 3fe0000000000000
3fe3333333333333 3fe3333333333334 3fe3333333333333
3fe6666666666666 3fe6666666666667 3fe6666666666666
3fe999999999999a 3fe999999999999a 3fe9999999999999
3feccccccccccccd 3feccccccccccccd 3feccccccccccccc
3ff0000000000000 3ff0000000000000 3fefffffffffffff
Some suggested readings (MATLAB related):