a curiosity: FLOAT returns double for single float
Subject: a curiosity: FLOAT returns double for single float
From: Raymond Toy
Date: Wed, 20 Jun 2012 09:09:03 -0700
On Wed, Jun 20, 2012 at 8:37 AM, Robert Dodier <robert.dodier at gmail.com>wrote:
> Hi, why does this happen?
>
> $ sh maxima-local -l clisp
> Maxima branch_5_27_base_135_gdf1376c_dirty http://maxima.sourceforge.net
> using Lisp CLISP 2.49 (2010-07-07)
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) :lisp (defparameter foo 1f0)
> FOO
> (%i1) :lisp (defparameter bar (float foo))
> BAR
> (%i1) :lisp (type-of foo)
> SINGLE-FLOAT
> (%i1) :lisp (type-of bar)
> DOUBLE-FLOAT
> (%i1) :lisp (eq foo bar)
> NIL
>
>
> I've tried this with Clisp, SBCL, and ABCL. They all give the same
> results. Incidentally without Maxima (just Lisp) the return value of
> (FLOAT 1f0) is single float.
>
> CLHS for FLOAT says that it returns its argument if the argument is a
> float and there is no prototype given. So I'm surprised to see that a
> double is returned for a single float argument.
>
> There is *READ-DEFAULT-FLOAT-FORMAT* which is DOUBLE-FLOAT in Maxima,
> but I wouldn't expect that to affect the function FLOAT.
>
>
Look for the FLOAT macro in clmacs.lisp.
I think I did this long ago because there are many uses of FLOAT in maxima,
but all uses of FLOAT implicitly assumed gcl's version of FLOAT. In gcl, a
double-float and single-float are the same and are 64-bit floats. Gcl's
short-float is a single-float.
Ray