all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25557: Documentation of format doesn't describe "g" accurately
@ 2017-01-27 22:05 Clément Pit--Claudel
  2017-01-28  8:37 ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Clément Pit--Claudel @ 2017-01-27 22:05 UTC (permalink / raw)
  To: 25557


[-- Attachment #1.1: Type: text/plain, Size: 1133 bytes --]

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.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-01-28 20:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-27 22:05 bug#25557: Documentation of format doesn't describe "g" accurately Clément Pit--Claudel
2017-01-28  8:37 ` Eli Zaretskii
2017-01-28 15:04   ` Clément Pit--Claudel
2017-01-28 15:23     ` Eli Zaretskii
2017-01-28 15:45       ` Clément Pit--Claudel
2017-01-28 16:01         ` Eli Zaretskii
2017-01-28 16:18           ` Clément Pit--Claudel
2017-01-28 16:25             ` Eli Zaretskii
2017-01-28 19:14               ` Clément Pit--Claudel
2017-01-28 19:31                 ` Eli Zaretskii
2017-01-28 20:06                   ` Clément Pit--Claudel
2017-01-28 20:29                     ` Eli Zaretskii
2017-01-28 20:45                       ` Clément Pit--Claudel

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.