printing floats (3/3), was: minor strangeness in cvs head maxima
Subject: printing floats (3/3), was: minor strangeness in cvs head maxima
From: Robert Dodier
Date: Wed, 12 Oct 2005 08:47:58 -0600
3rd message ...
Robert> An unrelated item -- entering 1.0 => 1. output. I don't
think it used
Robert> to be like that.
Robert> 1.0 => 1.0 in Maxima 5.9.2 / gcl & clisp,
Robert> 1.0 => 1. in Maxima 5.9.1 cvs / clisp & sbcl.
Ray>>>
Try the following replacement in exploden in src/commac.lisp.
((floatp symb)
(let ((a (abs symb)))
;; When printing out something for Fortran, we want to be
;; sure to print the exponent marker so that Fortran
;; knows what kind of number it is. It turns out that
;; Fortran's exponent markers are the same as Lisp's so
;; we just need to make sure the exponent marker is
;; printed.
;;
;; Also, for normal output, we basically want to use
;; prin1, but we can't because we want fpprec to control
;; how many digits are printed. So we have to check for
;; the size of the number and use ~e or ~f appropriately.
(multiple-value-bind (form width)
(if (or *fortran-print*
(zerop a)
(<= .001d0 a 10000000d0))
(values "~vf" (+ 1 $fpprec))
(values "~ve" (+ 5 $fpprec)))
(setq string (format nil form width symb)))
(setq string (string-trim " " string))))
This fixes the issue with 1.0 and 1.0d295. However, we now have a
problem if we want to use $fpprec to control the number of digits if
the number is between 0.001 and 1.
I need some guidance here. Perhaps this should be on the list? If
so, you can forward to this message (and all previous ones) to the
list too.
Ray