3 ms·
Because, due to the limited precision available to floating points, they are not precise. Example, given floats a, b, and c c = a - b might result in c ==
by fsloth 13y ago
Because, due to the limited precision available to floating points, they are not precise.
Example, given floats a, b, and c
c = a - b
might result in
c == a
There are volumes of literature related to this.
The short explanation why it is so, is that there is an infinite range of numbers, but we do not have infinite amount of memory, Therefore, to perform operations on very large (or very small) numbers efficiently (on current computer architecture) you need to round things around.
If you do not have time for a degree in maths, then at least go and read this before operating on any instructions on floating point in production code, thanks:
"What Every Computer Scientist Should Know About Floating Point Arithmetic"
http://www.validlab.com/goldberg/paper.pdf http://www.validlab.com/goldberg/paper.pdf
and
http://en.wikipedia.org/wiki/IEEE_floating_point http://en.wikipedia.org/wiki/IEEE_floating_point