[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Exponent sign printing with ~E
- To: CL-CLeanup@Sail.stanford.edu, Cassels@STONY-BROOK.SCRC.Symbolics.COM
- Subject: Exponent sign printing with ~E
- From: Robert A. Cassels <Cassels@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Tue, 13 Sep 88 15:11 EDT
- In-reply-to: <870703-173352-132@Xerox>
References: CLtL pp. 366, 393
Edit history: Bob Cassels, 13 Sep 88
Related issues: <none>
The result of (format nil "~E" 1.0) is specified in a contradictory way.
The ambiguity is whether a plus sign should be printed in front of
The top of page 393 says, "Next, either a plus or a minus sign is
printed, followed by e digits ... [decimal exponent]"
Later on page 393 we see, "If all of w, d, and e are omitted, then the
effect is ... [like prin1].
Page 366 [presumably where prin1 is defined] doesn't explicitly say that
the plus sign is omitted from the exponent, but all the examples (and
usual practice) indicate that.
So the posssibilities are:
The first reference implies that A is correct, the third reference
implies that B is correct. The second reference implies that A and B
are the same.
Change the wording on page 393 to:
"If all of w, d, and e are omitted, then the effect is to print the
value using ordinary free-format exponential-notation output; PRIN1 uses
a similar format for any non-zero number whose magnitude is less than
10**-3 or greater than or equal to 10**7. The only difference is that
the ~E directive always prints a plus or minus sign in front of the
exponent, while PRIN1 omits the plus sign if the exponent is
(format nil "~E" 1.0) => "1.0e+0"
This proposal makes ~E self-consistent. That is more important than
making ~E consistent with PRIN1.
Symbolics Common Lisp, Ibuki Lisp, and VAX Lisp all print the plus
sign as in the test case above. Apollo DOMAIN Common Lisp (version
2.10) produces "1.0", which is simply wrong.
Minimal changes to one printing routine for non-conforming
implementations. (No change to the three implementations mentioned
Cost of non-adoption:
Minor confusion and possible incompatibility among implementations.
Less confusion, more compatibility.
Minimal. It is doubtful that any user programs depend on this
A matter of opinion.
Fortran ~E format requires a sign before the exponent, since the exponent
mark character may be dropped. Since Common Lisp ~E always prints
the exponent marker, the exponent sign may be dropped in the case
that it would be a plus sign.