public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's
@ 2024-04-26  7:49 lcarreon at bigpond dot net.au
  2024-04-26  8:46 ` [Bug libstdc++/114863] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: lcarreon at bigpond dot net.au @ 2024-04-26  7:49 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2024-05-01  5:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26  7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
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

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).