[Cfp-interest 1373] Fwd: Re: (SC22WG14.16915) N2380: printf of NaN()
Fred J. Tydeman
tydeman at tybor.com
Wed Aug 14 12:59:34 PDT 2019
..................Begin Forwarded Message..................
From: "Fred J. Tydeman" <tydeman at tybor.com>
To: "Jim Thomas" <jaswthomas at sbcglobal.net>
Date: Sun, 11 Aug 2019 11:48:46 -0700 (PDT)
Subject: Re: (SC22WG14.16915) [Cfp-interest 1349] N2380: printf of NaN()
On Thu, 1 Aug 2019 09:36:13 -0700 Jim Thomas wrote:
>
>More generally, could you say what the implementations of printf you know about print for NaNs and infinities?
>
I tried the following program against:
gcc, clang, pcc, open64, Sun Studio
and they all printed just "nan".
/* printf of nan */
#include <stdio.h>
#include <math.h>
int main(void){
float f = NAN;
double d = NAN;
long double ld = NAN;
(void)printf(" f=%g\n", (double)f);
(void)printf(" d=%g\n", d);
(void)printf("ld=%Lg\n", ld);
(void)printf("123=%g\n", (double)nanf("123"));
(void)printf("123=%g\n", nan("123"));
(void)printf("123=%Lg\n", nanl("123"));
(void)printf("456=%g\n", (double)nanf("456"));
(void)printf("456=%g\n", nan("456"));
(void)printf("456=%Lg\n", nanl("456"));
(void)printf("dead=%16.12g\n", (double)nanf("deadbeef"));
(void)printf("dead=%16.12g\n", nan("deadbeef"));
(void)printf("dead=%16.12Lg\n", nanl("deadbeef"));
(void)printf("deada=%a\n", (double)nanf("deadbeef"));
(void)printf("deada=%a\n", nan("deadbeef"));
(void)printf("deada=%La\n", nanl("deadbeef"));
(void)printf("dead#=%#a\n", (double)nanf("deadbeef"));
(void)printf("dead#=%#a\n", nan("deadbeef"));
(void)printf("dead#=%#La\n", nanl("deadbeef"));
return 0;
}
---
Fred J. Tydeman Tydeman Consulting
tydeman at tybor.com Testing, numerics, programming
+1 (702) 608-6093 Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.
...................End Forwarded Message..................
---
Fred J. Tydeman Tydeman Consulting
tydeman at tybor.com Testing, numerics, programming
+1 (702) 608-6093 Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.
More information about the Cfp-interest
mailing list