Why is the 100*0.07 equal to 6.9999....?
matlab
Solution
The problem is that 0.01 cannot be exactly represented in binary floating-point. Neither can 0.07.
Problem
One of my friends wrote the following in Matlab and the outputs are little weird: ``` for p=0.01:0.01:0.1 100*p end ``` The following was the output: ``` 1 2 3 4 5 6.000000000000001 6.999999999999999 8 9 10 ``` I'd like to know why there is a slight error? Does this mean that, the accuracy in the general case is also as poor as it is in this case? EDIT: We compared the numbers -- `7==6.999999999999999` and the output was `0`. So, Matlab contradicts itself!