Menu

#3099 Float read is single-precision, though float() is double-precision

None
closed
nobody
5
2016-02-24
2016-02-23
No

In Maxima on SBCL 1.1.8, when there is no explicit exponent in floating-point input, it is read as a single float. (Is this an SBCL bug? I don't see it in Maxima 5.36 on SBCL 1.2.10.)

foo: [1.0, 1.0e0, 1.0d0, float(1)]$
:lisp (mapcar 'type-of (cdr $foo))
=>
(SINGLE-FLOAT DOUBLE-FLOAT DOUBLE-FLOAT DOUBLE-FLOAT)

Maxima 5.37post (built 2016-02-22 19:29:21)
SBCL 1.1.8.0-19cda10 on MacOS 10.11.3

Discussion

  • Stavros Macrakis

    Re-tested on Maxima 5.37post, SBCL 1.2.11, same result.
    SBCL 1.2.11 is the most up-to-date binary available for OSX/AMD64 at http://www.sbcl.org/platform-table.html . Only Windows and Linux have more recent binaries.

     
  • Robert Dodier

    Robert Dodier - 2016-02-24

    It appears that *READ-DEFAULT-FLOAT-FORMAT* needs to be set to DOUBLE-FLOAT for SBCL. (Apparently that's the default for some installations of SBCL, but at some, including yours it appears, have SINGLE-FLOAT.)

    See INITIALIZE-RUNTIME-GLOBALS in src/init-cl.lisp. There is already some implementation-specific code there for the float format; I guess we need something for SBCL too.

     
  • Robert Dodier

    Robert Dodier - 2016-02-24

    To verify -- what does :lisp *READ-DEFAULT-FLOAT-FORMAT* report on your system?

     
  • Stavros Macrakis

    READ-DEFAULT-FLOAT-FORMAT => single-float
    setting it to double-float fixes the problem

     
  • Robert Dodier

    Robert Dodier - 2016-02-24
    • labels: --> floating point, sbcl
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2016-02-24

    Fixed by commit 0443536. Closing this report accordingly.

     

Log in to post a comment.