unpretty FORMAT ~E printing

Bug #883520 reported by Nikodemus Siivola on 2011-10-29
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

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


| * (lisp-implementation-version)
| ""
| * (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".


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
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"

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

Other bug subscribers