From: Dave K. <ip...@gm...> - 2006-04-25 17:09:34
|
Applies fine and works great. Thanks. On 4/25/06, Raymond Toy <ray...@er...> wrote: > >>>>> "Dave" =3D=3D Dave Kern <ip...@gm...> writes: > > Dave> In sbcl-0.9.11 running under linux on an x86 machine: > Dave> When I use format with "~F" and specify the number of fraction = digits, > Dave> an extra digit is output if the input is a "small number". Hope= fully > Dave> the following makes it clear: > > Dave> (format t "~,2F" 0.001) =3D> 0.001 ;; should be 0.00 > Dave> (format t "~,2F" 0.005) =3D> 0.005 ;; should be 0.00 or 0.01 > Dave> (format t "~,2F" 0.006) =3D> 0.01 ;; correct > > CMUCL has a similar problem. One possible fix is the following > patch. This should probably apply cleanly to sbcl, since they both > have very similar fp printing routines. > > Ray > > In function flonum-to-string: > Index: print.lisp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /project/cmucl/cvsroot/src/code/print.lisp,v > retrieving revision 1.108 > diff -u -r1.108 print.lisp > --- print.lisp 17 Feb 2006 15:45:40 -0000 1.108 > +++ print.lisp 25 Apr 2006 13:24:15 -0000 > @@ -1539,7 +1539,11 @@ > (write-string "." stream) > (dotimes (i (- e)) > (write-char #\0 stream)) > - (write-string string stream) > + ;; If we're out of room (because fdigits is too > + ;; small), don't print out our string. > + (when (or (null fdigits) > + (plusp (+ e fdigits))) > + (write-string string stream)) > (when fdigits > (dotimes (i (+ fdigits e (- (length string)))) > (write-char #\0 stream))))) > > |