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/
.



Relevant Pages

  • Re: (* 2.4 3) => 7.2000003 WTF?! Lets Fix Lisp! Noob Programming Challenge
    ... 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 ... please adjust your expectations. ...
    (comp.lang.lisp)
  • Re: simple question on printing double precision numbers.
    ... what's the digits are after the decimal at position 18? ... plus an unknown amount of roundoff error. ... The result of the function COSis a double precision floating ...
    (comp.lang.fortran)
  • Re: matrix inversion roundoff error
    ... Roundoff error does ... Thus, to 3 digits, measurement errors would make the solution of this ... good to 3 more digits, the problem is simply a mild loss of precision. ... Systems which are ill-conditioned to a given precision may well be OK ...
    (comp.sys.hp48)
  • Re: Format a number
    ... handle twelve digits; and a Double will have roundoff error. ... You'll never be doing math with this value. ... Come for live chats every Tuesday and Thursday ...
    (microsoft.public.access.formscoding)