Currency calculations

As part of your new program, you need to 'count' money from £0.0 to £1.00 in steps of 10p, but you notice that your computer generates some odd results. So you compile a table of the actual results versus the expected results, and the output is as follows:

Expected ResultActual ResultPass/Fail
£0.0£0.0Pass
£0.1£0.1Pass
£0.2£0.2Pass
£0.3£0.30000000000000004Fail
£0.4£0.4Pass
£0.5£0.5Pass
£0.6£0.6Pass
£0.7£0.7Pass
£0.8£0.7999999999999999Fail
£0.9£0.8999999999999999Fail
£1.0£0.9999999999999999Fail

Why is the program's answer different from what you might expect--surely adding 10p is simple?

×

Problem Loading...

Note Loading...

Set Loading...