128 lines
5.8 KiB
HTML
128 lines
5.8 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Issue FORMAT-E-EXPONENT-SIGN Writeup</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="../Issues/iss166_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss167.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss168_w.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss166_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss167.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss168_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue FORMAT-E-EXPONENT-SIGN Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> Passed, Jan 89 X3J13<P>
|
|
<B>Forum:</B> Cleanup<P>
|
|
<B>Issue:</B> <A HREF="iss167.htm">FORMAT-E-EXPONENT-SIGN</A><P>
|
|
<P>
|
|
<B>References:</B> CLtL pp. 366, 393<P>
|
|
<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<P>
|
|
<B>Edit history:</B> Bob Cassels, 13 Sep 88<P>
|
|
Masinter, 2-Oct-88 (change issue name)<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
The result of (format nil "~E" 1.0) is specified in a contradictory way.<P>
|
|
The ambiguity is whether a plus sign should be printed in front of<P>
|
|
the exponent.<P>
|
|
<P>
|
|
The top of page 393 says, "Next, either a plus or a minus sign is<P>
|
|
printed, followed by e digits ... [decimal exponent]"<P>
|
|
<P>
|
|
Later on page 393 we see, "If all of w, d, and e are omitted, then the<P>
|
|
effect is ... [like prin1].<P>
|
|
<P>
|
|
Page 366 [presumably where prin1 is defined] doesn't explicitly say that<P>
|
|
the plus sign is omitted from the exponent, but all the examples (and<P>
|
|
usual practice) indicate that.<P>
|
|
<P>
|
|
So the posssibilities are:<P>
|
|
<P>
|
|
A. "1.0e+0"<P>
|
|
B. "1.0e0"<P>
|
|
<P>
|
|
The first reference implies that A is correct, the third reference<P>
|
|
implies that B is correct. The second reference implies that A and B<P>
|
|
are the same.<P>
|
|
<P>
|
|
<B>Proposal (FORMAT-E-EXPONENT-SIGN:FORCE-SIGN):<P>
|
|
</B><P>
|
|
Specify that ~E always prints a plus or minus sign in front of the<P>
|
|
exponent.<P>
|
|
<P>
|
|
This would cause the language on page 393 of CLtL to to change:<P>
|
|
<P>
|
|
"If all of w, d, and e are omitted, then the effect is to print the<P>
|
|
value using ordinary free-format exponential-notation output; <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#prin1"><B>PRIN1</B></A> uses<P>
|
|
a similar format for any non-zero number whose magnitude is less than<P>
|
|
10**-3 or greater than or equal to 10**7. The only difference is that<P>
|
|
the ~E directive always prints a plus or minus sign in front of the<P>
|
|
exponent, while <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#prin1"><B>PRIN1</B></A> omits the plus sign if the exponent is<P>
|
|
non-negative."<P>
|
|
<P>
|
|
<B>Test Case:<P>
|
|
</B><P>
|
|
(format nil "~E" 1.0) => "1.0e+0"<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
This proposal makes ~E self-consistent. That is more important than<P>
|
|
making ~E consistent with <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#prin1"><B>PRIN1</B></A>.<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
Symbolics Common Lisp, Ibuki Lisp, and VAX Lisp all print the plus<P>
|
|
sign as in the test case above. Apollo DOMAIN Common Lisp (version<P>
|
|
2.10) and Xerox Common Lisp produce "1.0", which is wrong because <P>
|
|
it includes no exponent at all.<P>
|
|
<P>
|
|
<B>Adoption Cost:<P>
|
|
</B><P>
|
|
Minimal changes to one printing routine for non-conforming<P>
|
|
implementations. (No change to the three implementations mentioned<P>
|
|
above.)<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
Minor confusion and possible incompatibility among implementations.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Less confusion, more compatibility.<P>
|
|
<P>
|
|
<B>Conversion Cost:<P>
|
|
</B><P>
|
|
Minimal. It is doubtful that any user programs depend on this<P>
|
|
obscure distinction.<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
A matter of opinion.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Fortran ~E format requires a sign before the exponent, since the exponent<P>
|
|
mark character may be dropped. Since Common Lisp ~E always prints<P>
|
|
the exponent marker, the exponent sign may be dropped in the case<P>
|
|
that it would be a plus sign.<P>
|
|
<P>
|
|
</PRE>
|
|
<HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|