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

Re: floats



Sam Steingold <sshteingold@cctrading.com> writes:
> 
>      I am having a *very* nasty problem. I want all my floats to be double. 
>      Always. I set *default-float-format* to 'double-float, *and* set the 
>      vars as 0.0d0. And still end up with numbers like 644151.75f0.

When you read floats from files, you also need to have
*read-default-float-format* = double-float.

>      This can be traced to 
>      
>      > (+ 0.0d0 1233456.2345f0)
>      
>      1233456.3f0
>      >
>      
>      which is quite outrageous, since *I* would expect it to be double on 
>      the grounds of double + single = double no matter what! :-)

This is a different issue: Once your data is already infected with
single-floats, does this disease spread or not? In ANSI CL compliant
systems, the double-floats take over again but inaccuracies spread
nevertheless under cover. In CLISP, with the rule "double + single = single",
the single-floats spread, so it's easier for you to detect them.

For more explanations, see section 12.1. of
ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/lisp/clisp/impnotes.html

                           Bruno