Re: (* 2.4 3) => 7.2000003 WTF?! Let's Fix Lisp! Noob Programming Challenge



On Wed, 20 Dec 2006 15:50:38 +0100, Ken Tilton <kentilton@xxxxxxxxx> wrote:


You gotta love Lisp, it even puts its bugs in the standard. "It is OK to blow the arithmetic, just tell us how much."***

kenny


This is no bug. It is impossible to describe a irrational/trancendental
number with a finite number of digits.
Further the numbers which can be represented eactly will vary with
the number system 0.2 = 1/5 fine in a decimal system with primes 2 and 5
but not in a binary whith only prime 2.
1/4 = 0.25 has no roundoff error.
But performing the transform is rather trivial and the performance
penalty of using decimal representation would make it useless for many
applications.
It is standard in all computation to give a error value epsilon and then check
that error < epsilon. So 1/4 = .25 is wrong 1/4 - 0.25 < epsilon right..
If you don't want your students to worry about it you will just have
to set one for them. 10^-6 should be fine I guess.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
.