I am just starting to learn TCL. On its Tutorial page, there is a part of description as the following:
1.2 / 0.1 results in 11.999999999999998, not 12. That is an example of a very nasty aspect of most computers and programming languages today: they do not work with ordinary decimal fractions, but with binary fractions. So, 0.5 can be represented exactly, but 0.1 can not.
I don't know what exactly this means. I have tried the followings:
% expr {1.2 / 0.1}
11.999999999999998
% expr {1.2 / 0.5}
2.4
% expr {1.2 / 0.4}
2.9999999999999996
% expr {1.2 / 0.3}
4.0
Like it describes, 1.2 / 0.5 will give the exact answer. But with 0.1 as divisor, it won't.
Could anyone kindly explain what the mechanism is here? Thanks.