a curiosity: FLOAT returns double for single float
Subject: a curiosity: FLOAT returns double for single float
From: Robert Dodier
Date: Wed, 20 Jun 2012 15:37:18 +0000 (UTC)
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.
best
Robert Dodier