Subject: bug#25557: closed (Re: bug#25557: Documentation of format doesn't describe "g" accurately)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 28 Jan 2017 08:38:02 +0000

Your bug report

#25557: Documentation of format doesn't describe "g" accurately

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
25557: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25557
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
From: Eli Zaretskii <[email-masked]>
To: Clément Pit--Claudel <[email-masked]>
Cc: [email-masked]
Date: Sat, 28 Jan 2017 10:37:25 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Clément Pit--Claudel <[email-masked]>
> Date: Fri, 27 Jan 2017 17:05:28 -0500
> 
> There seems to be a few issues in the docstring of `format':
> 
> > %g means print a number in exponential notation
> >  or decimal-point notation, whichever uses fewer characters.
> 
> This seems wrong:
> 
>   (format "%g" 3.0) ⇒ "3", but
>   (format "%f" 3.0) ⇒ "3.000000", and
>   (format "%e" 3.0) ⇒ "3.000000e+00", so %g is neither %f nor %e.

Fixed.

> > The # flag means to use an alternate display form [...]
> > for %e, %f, and %g, it causes a decimal point to be included even if
> > the precision is zero.
> 
> This seems incomplete:
> 
>   (format "%#.5g" 3) ⇒ "3.0000", while
>   (format "%.5g" 3) ⇒ "3", so # doesn't just cause changes when the precision is 0.

I don't understand what you are trying to say (nor the significance of
the '.'  flag in the example).  '#' forces %g to leave the trailing
zeros after the decimal, so I added that -- is that what you wanted to
say?

> > For %e, %f, and %g sequences, the number after the "." in the
> > precision specifier says how many decimal places to show
> 
> This seems wrong, too:
> 
>   (format "%.5g" 3.0) ⇒ "3", not "3.00000"
>   (format "%.5g" 3.1) ⇒ "3.1", not "3.10000"

Fixed.

> Similar problems seem to exist in the actual documentation.

If you mean the ELisp manual, I fixed that as well.

> On a related note, is there a way to get a shortest representation of a number? Something like %g, but without exponents.

Sorry, I don't understand the question.  How can you represent an
arbitrary number without exponents at all, except by %f?

Anyway, thanks; I'm marking this bug done.

Subject: Documentation of format doesn't describe "g" accurately
From: Clément Pit--Claudel <[email-masked]>
To: [email-masked]
Date: Fri, 27 Jan 2017 17:05:28 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi emacs,

There seems to be a few issues in the docstring of `format':

> %g means print a number in exponential notation
>  or decimal-point notation, whichever uses fewer characters.

This seems wrong:

  (format "%g" 3.0) ⇒ "3", but
  (format "%f" 3.0) ⇒ "3.000000", and
  (format "%e" 3.0) ⇒ "3.000000e+00", so %g is neither %f nor %e.

> The # flag means to use an alternate display form [...]
> for %e, %f, and %g, it causes a decimal point to be included even if
> the precision is zero.

This seems incomplete:

  (format "%#.5g" 3) ⇒ "3.0000", while
  (format "%.5g" 3) ⇒ "3", so # doesn't just cause changes when the precision is 0.

> For %e, %f, and %g sequences, the number after the "." in the
> precision specifier says how many decimal places to show

This seems wrong, too:

  (format "%.5g" 3.0) ⇒ "3", not "3.00000"
  (format "%.5g" 3.1) ⇒ "3.1", not "3.10000"

Similar problems seem to exist in the actual documentation. On a related note, is there a way to get a shortest representation of a number? Something like %g, but without exponents.

Thanks!
Clément.