[Bug 277612] libc printf not compatible with glibc with negative nan

2024-03-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277612

--- Comment #2 from Paul Floyd  ---
The C standard clearly states that it is implementation defined.

This is about compatibility with glibc.

-- 
You are receiving this mail because:
You are the assignee for the bug.


[Bug 277612] libc printf not compatible with glibc with negative nan

2024-03-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277612

Benjamin Takacs  changed:

   What|Removed |Added

 CC||nimaje+...@bureaucracy.de

--- Comment #1 from Benjamin Takacs  ---
There is no such thing as a "negative nan", just some nan representation where
the signbit is set and some where it is not, but that should be just a nan for
every purpose. I would say not printing a sign there is clearer, as nobody can
be confused that something like a "negative nan" exists. And that   sign =
'\0';   in line 788 seems to be an explicite design desicion to do that to me.

-- 
You are receiving this mail because:
You are the assignee for the bug.


[Bug 277612] libc printf not compatible with glibc with negative nan

2024-03-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277612

Bug ID: 277612
   Summary: libc printf not compatible with glibc with negative
nan
   Product: Base System
   Version: 14.0-RELEASE
  Hardware: Any
OS: Any
Status: New
  Severity: Affects Only Me
  Priority: ---
 Component: misc
  Assignee: b...@freebsd.org
  Reporter: pjfl...@wanadoo.fr

I think that it would be better for compatibility for printf of negative nans
to include the minus sign.

The C standard does say

A double argument representing an infinity is converted in one of the styles
[-]inf or
[-]infinity — which style is implementation-defined. A double argument
representing a
NaN is converted in one of the styles [-]nan or [-]nan(n-char-sequence) — which
style and 
the meaning of any n-char-sequence, is implementation-defined. The F conversion
specifier
produces INF, INFINITY, or NAN instead of inf, infinity, or nan,
respectively.337)

>From what I see the cod that controls this is

│  >   785  if (expt == INT_MAX) {  /* inf or nan */
│  786  if (*cp == 'N') {
│  787  cp = (ch >= 'a') ? "nan" :
"NAN";
│  788  sign = '\0';

in vfprintf.c

-- 
You are receiving this mail because:
You are the assignee for the bug.