[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Clément Pit--Claudel
Subject: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Fri, 27 Jan 2017 17:05:28 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

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.


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]