double floats

Ben Hyde bhyde at pobox.com
Mon May 6 01:59:24 UTC 2013


Double floats cause issues with the compiler 

md> (setf *read-default-float-format* 'double-float)
double-float
md> (ps '(1.0 2.0 3.0))
"[1.0D0, 2.0D0, 3.0D0];"

since 1.0D0 isn't javascript

This is a simpler example:

md> (ps 1.0D0)
"1.0D0;"

Adding...

(defmethod ps-print ((x double-float))
  (format *psw-stream* "~F" (coerce x 'single-float)))

to printer.lisp resolves the problem.

At which point it's tempting to rework the ps-print method on number with:

(defmethod ps-print ((x double-float))
  (format *psw-stream* "~F" (coerce x 'single-float)))

(defmethod ps-print ((x integer))
  (format *psw-stream* "~D" x))

(defmethod ps-print ((x number))
  (format *psw-stream* "~F" x))

Thanks for this awesome tool!   - ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/parenscript-devel/attachments/20130505/7fc8d457/attachment.html>


More information about the parenscript-devel mailing list