public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lcarreon at bigpond dot net.au" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's
Date: Fri, 26 Apr 2024 07:49:21 +0000	[thread overview]
Message-ID: <bug-114863-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863

            Bug ID: 114863
           Summary: std::format applying grouping to nan's and inf's
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lcarreon at bigpond dot net.au
  Target Milestone: ---

The following code:

#include <locale>
#include <limits>
#include <iostream>
#include <format>

int main()
{
  std::locale::global(std::locale{"en_AU.utf8"});

  double values[] =
  {
    std::numeric_limits<double>::quiet_NaN(),
    -std::numeric_limits<double>::quiet_NaN(),
    std::numeric_limits<double>::signaling_NaN(),
    -std::numeric_limits<double>::signaling_NaN(),
    std::numeric_limits<double>::infinity(),
    -std::numeric_limits<double>::infinity()
  };

  for (const auto& value : values)
  {
    std::cout << std::format("{0:Le}  {0:Lf}  {0:Lg}", value) << std::endl;
  }

  return 0;
}

Generates the following output:

nan  nan  nan
-,nan  -,nan  -,nan
nan  nan  nan
-,nan  -,nan  -,nan
inf  inf  inf
-,inf  -,inf  -,inf

Which in my opinion is incorrect because it applied thousands separator
grouping.  Grouping should only be applied to finite values displayed in fixed
format.

             reply	other threads:[~2024-04-26  7:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26  7:49 lcarreon at bigpond dot net.au [this message]
2024-04-26  8:46 ` [Bug libstdc++/114863] " redi at gcc dot gnu.org
2024-04-26 10:06 ` redi at gcc dot gnu.org
2024-04-26 10:19 ` redi at gcc dot gnu.org
2024-04-26 15:03 ` cvs-commit at gcc dot gnu.org
2024-04-30  8:36 ` cvs-commit at gcc dot gnu.org
2024-04-30 20:20 ` cvs-commit at gcc dot gnu.org
2024-04-30 20:22 ` redi at gcc dot gnu.org
2024-05-01  5:37 ` lcarreon at bigpond dot net.au

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

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

  git send-email \
    --in-reply-to=bug-114863-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.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).