unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#33773: Problem with format ~g mantdigits argument
@ 2018-12-16 20:11 Luther Thompson
  0 siblings, 0 replies; only message in thread
From: Luther Thompson @ 2018-12-16 20:11 UTC (permalink / raw)
  To: 33773

I'm running Guile 2.2.4 on GuixSD.

In the documentation for `format`[0], under `~g`, it says this about
the mantdigits argument:

"When fixed-point is used, the decimals parameter to ~f is established
from mantdigits, so as to give a total mantdigits+1 figures."

The example just above this sentence contradicts this, as we can see
here:

---BEGIN---
$ guile
GNU Guile 2.2.4
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (format #f "~,4g" 999)
$1 = "999.0    "
scheme@(guile-user)> (format #f "~,4g" 100000)
$2 = "1.0000E+5"
---END---

When ~g uses fixed-point, it shows mantdigits significant digits. When
~g uses an exponent, it shows mantdigits+1 significant digits.

I think it's important that ~g does not change the number of
significant digits depending on fixed-point vs. exponential.

Also, I think ~g should show a number of significant digits equal to
mantdigits. In my opinion, this would be more intuitive than adding 1,
and would be more in line with C's printf. (I figure it's worth it to
ask for this, because fixing this bug means having to choose between
the two behaviors anyway. I don't know if backward compatibility
factors into this.)

uname -a:
Linux targaryen 4.19.6-gnu #1 SMP 1 x86_64 GNU/Linux

[0]
https://www.gnu.org/software/guile/manual/html_node/Formatted-Output.html#Formatted-Output

Luther





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-16 20:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-16 20:11 bug#33773: Problem with format ~g mantdigits argument Luther Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).