[Sbcl-devel] Exponential output from ~g format always has "0" as last digit From: Liam M. Healy - 2005-03-10 03:50 ```There is always a zero for the last digit in ~g formatted output when the exponential form is used: (format nil "~9,6g" (* pi 1e8)) "3.141590e+8" (format nil "~9,5g" (* pi 1e8)) "3.14160e+8" (format nil "~9,4g" (* pi 1e8)) "3.1420e+8" (format nil "~9,3g" (* pi 1e8)) " 3.140e+8" (format nil "~9,2g" (* pi 1e8)) " 3.10e+8" This is incorrect. This is on SBCL 0.8.19.15 on Linux i386; sent also to cmucl at the request of rtoym who believes it will display the same behavior. Liam ```
 Re: [Sbcl-devel] Exponential output from ~g format always has "0" as last digit From: Simon Alexander - 2005-03-10 04:44 Attachments: diff ```I'll have to think about it tomorrow, when I'm more awake. Attached patch will fix this behaviour, but I'm too sleepy to convince myself it doesn't screw anything else up :) s. On Wed, 9 Mar 2005 22:50:30 -0500 (EST), Liam M. Healy wrote: > There is always a zero for the last digit in ~g formatted output when > the exponential form is used: > > (format nil "~9,6g" (* pi 1e8)) > "3.141590e+8" > (format nil "~9,5g" (* pi 1e8)) > "3.14160e+8" > (format nil "~9,4g" (* pi 1e8)) > "3.1420e+8" > (format nil "~9,3g" (* pi 1e8)) > " 3.140e+8" > (format nil "~9,2g" (* pi 1e8)) > " 3.10e+8" > > This is incorrect. > > This is on SBCL 0.8.19.15 on Linux i386; sent also to cmucl at the > request of rtoym who believes it will display the same behavior. > > Liam > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Sbcl-devel mailing list > Sbcl-devel@... > https://lists.sourceforge.net/lists/listinfo/sbcl-devel > ```
 Re: [Sbcl-devel] Exponential output from ~g format always has "0" as last digit From: Raymond Toy - 2005-03-10 15:09 ```>>>>> "Simon" == Simon Alexander writes: Simon> I'll have to think about it tomorrow, when I'm more awake. Attached Simon> patch will fix this behaviour, but I'm too sleepy to convince myself Simon> it doesn't screw anything else up :) [snip] Simon> diff -u -r1.27 target-format.lisp Simon> --- src/code/target-format.lisp 28 Jan 2005 16:49:00 -0000 1.27 Simon> +++ src/code/target-format.lisp 10 Mar 2005 04:39:43 -0000 Simon> @@ -590,7 +590,7 @@ Simon> (estr (decimal-string (abs expt))) Simon> (elen (if e (max (length estr) e) (length estr))) Simon> (fdig (if d (if (plusp k) (1+ (- d k)) d) nil)) Simon> - (fmin (if (minusp k) (- 1 k) nil)) Simon> + (fmin (if (minusp k) (- 1 k) (1+ fdig))) Simon> (spaceleft (if w Simon> (- w 2 elen Simon> (if (or atsign (minusp (float-sign number))) This seems reasonable. It will take some time for me to figure out float printing again, though. :-( Ray ```
 Re: [Sbcl-devel] Exponential output from ~g format always has "0" as last digit From: Simon Alexander - 2005-03-11 18:42 Attachments: diff ```Yes, the printing code is not immediately obvious. There is a simple bug in the diff I sent earlier ("~G" strings are ok, but "~E" are broken). Here is a revised patch which gets those cases, passes the sbcl tests, and looks ok from my superficial understanding of format-general and format-exponential... Simon On Thu, 10 Mar 2005 10:07:00 -0500, Raymond Toy wrote: > This seems reasonable. It will take some time for me to figure out > float printing again, though. :-( > > Ray > > ```
 Re: [Sbcl-devel] Exponential output from ~g format always has "0" as last digit From: Christophe Rhodes - 2005-11-08 20:39 ```Simon Alexander writes: > Yes, the printing code is not immediately obvious. There is a simple > bug in the diff I sent earlier ("~G" strings are ok, but "~E" are > broken). Here is a revised patch which gets those cases, passes the > sbcl tests, and looks ok from my superficial understanding of > format-general and format-exponential... At Simon's request, I have merged his updated patch dealing with this issue as sbcl-0.9.6.34. Thanks, Christophe ```