|
In article <figsde$cj9$1@fred.mathworks.com>, Marco Pappalepore wrote:
> if one writes in Matlab
>
> >> 0.999999992 + 0.000000002
>
> he gets
>
> ans =
>
> 9.999999940000001e-001
>
> the strange result is that decimal 1 on the right.
>
> Is that normal ? Is that IEEE-754 conformant ?
>
> Where can I find the exact sum algorithm of matlab in order
> to learn when to expect such a behaviour ?
>
> many thanks
Not all decimal numbers have exact representations in binary, hence the
spurious '1' when calculating with a computer doing binary arithmetic.
Training in how binary digital computers do arithmetic, and how to
minimise the calculation errors that can therefore result from the
conversions from decimal > binary > decimal are (or at least were) an
integral part of most basic courses on computing - and an essential
knowledge for scientific and engineering users.
(Note that pocket calculators work in binary-coded-decimal, which is
accurate for decimal calculations.)
|