unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Luther Thompson <lutheroto@gmail.com>
To: 33773@debbugs.gnu.org
Subject: bug#33773: Problem with format ~g mantdigits argument
Date: Sun, 16 Dec 2018 15:11:20 -0500	[thread overview]
Message-ID: <20181216151120.0356bcd9@gmail.com> (raw)

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





                 reply	other threads:[~2018-12-16 20:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181216151120.0356bcd9@gmail.com \
    --to=lutheroto@gmail.com \
    --cc=33773@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).