Steel Bank Common Lisp

unpretty FORMAT ~E printing

Reported by Nikodemus Siivola on 2011-10-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

Bug Description

Eric Marsden <email address hidden> via lists.sourceforge.net to sbcl-devel

Hi,

,----
| * (lisp-implementation-version)
| "1.0.50.54-5abf3b4"
| * (FORMAT NIL "~E" 1.0)
| "1.e+0"
| * (FORMAT NIL "~E" 1.0d0)
| "1.d+0"
`----

My reading of CLHS ("If all of w, d, and e are omitted, then the effect
is to print the value using ordinary free-format exponential-notation
output") suggests that those should be "1.0e+0" and "1.0d+0".

 http://www.lispworks.com/documentation/HyperSpec/Body/22_ccb.htm

Nikodemus Siivola (nikodemus) wrote :

Alexnader Klimov says:

Unless "ordinary" is defined (I cannot find such a definition in the
specification), it is reasonable to understand "ordinary" as the form
without any redundant characters, that is for fixed-format it is "1.0"
(the zero is required since "1." is an integer), but for the
exponential notation "1.e+0" is sufficient (actually, "1.e0" is also
enough, but "+" is explicitly required).

As a hint that "1.e+0" is a better interpretation of Section 22.3.3.2
we can consider

 If the parameter d is omitted, then there is no constraint on the
 number of digits to appear. A value is chosen for d in such a way
 that as many digits as possible may be printed subject to the width
 constraint imposed by the parameter w, the constraint of the scale
 factor k, and the constraint that no trailing zero digits may appear
 in the fraction, except that if the fraction to be printed is zero
 then a single zero digit should appear after the decimal point.

and thus "1.0e+0" would violate the "no trailing zero digits"
requirement.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers