Comment on Worksheet 3, Exercise 2
by
M.Kerber
There was a question about problems with float/double computation. It
may happen that if you take for instance 1.15 and subtract 1 that you
get something like 0.14999999999.
In this exercise it is fine to print
1
.
1
4
9
9
9
9
9
9
9
9
9
However, you can understand from this example my reluctance this
morning to represent the balance of a bank account with a variable of
type float or double. It may mean that you have pounds 15 in your
account, withdraw pounds 5 and are left with pounds 9.99999999999.
Post a Comment