Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Dec 2014 14:16:37 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        freebsd-standards@FreeBSD.org
Subject:   Does posix say anything about the sign in NaNs ?
Message-ID:  <549B1115.8000909@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------070302050101030406080200
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

Hello;

I got the attached patch from OpenBSD.

It says:
____
Show the sign for NaN as per POSIX; from Elliott Hughes.
ok martynas@, millert@, doug@
____

I can't find a reference in POSIX documentation to support it though.

Anyone has a reason why we shouldn't adopt it, or a reference I can quote
on the commit log?

Regards,

Pedro.

ps. Merry Christmas to everyone !!


--------------070302050101030406080200
Content-Type: text/x-patch;
 name="stdio-vfprintf-nan.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="stdio-vfprintf-nan.diff"

Index: lib/libc/stdio/vfprintf.c
===================================================================
--- lib/libc/stdio/vfprintf.c	(revision 276188)
+++ lib/libc/stdio/vfprintf.c	(working copy)
@@ -721,10 +721,9 @@
 			if (signflag)
 				sign = '-';
 			if (expt == INT_MAX) {	/* inf or nan */
-				if (*cp == 'N') {
+				if (*cp == 'N')
 					cp = (ch >= 'a') ? "nan" : "NAN";
-					sign = '\0';
-				} else
+				else
 					cp = (ch >= 'a') ? "inf" : "INF";
 				size = 3;
 				flags &= ~ZEROPAD;
Index: lib/libc/stdio/vfwprintf.c
===================================================================
--- lib/libc/stdio/vfwprintf.c	(revision 276188)
+++ lib/libc/stdio/vfwprintf.c	(working copy)
@@ -788,10 +788,9 @@
 			if (signflag)
 				sign = '-';
 			if (expt == INT_MAX) {	/* inf or nan */
-				if (*cp == 'N') {
+				if (*cp == 'N')
 					cp = (ch >= 'a') ? L"nan" : L"NAN";
-					sign = '\0';
-				} else
+				else
 					cp = (ch >= 'a') ? L"inf" : L"INF";
 				size = 3;
 				flags &= ~ZEROPAD;

--------------070302050101030406080200--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?549B1115.8000909>