[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accuracy of floating point computation in MCL



In article <1991Nov28.213622.21841@watdragon.waterloo.edu>, melewis@jeeves.waterloo.edu (Michael Lewis) writes:
> There seems to be a pervasive and important error in floating point
> calculations in MCL.

To which I had some kind and gentle remarks and introductory essays on
floating point arithmetic.  Thanks to those concerned but my point must 
have been hidden in my message.  Sorry.
The real import of my comment deals with floating point contagion in MCL.

 From my previous message:
>  .
>  .
>  .
>    ** stuff deleted **

Again consider:

> ? (- .3 3/10)
> -1.111307226797642E-17
> ? 
> 
> And my favourite is 
> 
> ? (> 3/10 .3)
> T
> 
> Imagine the consequences!
> 

The question is why isn't 3/10 coerced to  the same representation as 0.3?
For example in Franz Common Lisp we have 

<cl> (- .3 3/10)

0.0

and consequently:

<cl> (< 3/10 0.3)
NIL

and

<cl> (< .3 3/10)
NIL

Note also that in MCL 2.0 we have:

? (- .3 (/ (float 3) (float 10)))
0.0

and

? (float 3/10)
0.3

One person (jhowland%ariel.cs.trinity.edu) mentioned that J (a descendent
of APL) permits a user determined tolerance for arithmetic comparisons.
Has anyone  done this in MCL?  In general CL?


The following example was mentioned to show that when there is an exact
binary representation, things are ok.

> Note however that 
> (- 1/2 .5) yields 0.0
> as does
> (- 1/8 .125)
> 

So I repeat:
> As our application here depends *critically* on *accurate*
> numerical calculations we were wondering exactly how we could get MCL
> to "do the right thing"!
> 

Thanks in advance for your comments.