But why the following?
0.15 * 2 = 0.3
The result isn't exactly 0.3, but it's close enough so that when the least significant digits are rounded off to display the value, it's rounded to 0.3.
The values 0.1
and 0.15
are not exact either, but the error representing 0.1
seems to be larger than for 0.15
. When you use the values in calculations, the errors accumulate, and sooner or later they become large enough not to be rounded off when the values are displayed.