From: Martin Stromberg Date: Mon, 27 Mar 2000 10:03:18 +0200 (MET DST) Message-Id: <200003270803.KAA29749@lws256.lu.erisoft.se> To: djgpp-workers AT delorie DOT com Subject: (fwd) Re: "[-]nan" in C99 Newsgroups: comp.std.c Content-Type: text Reply-To: djgpp-workers AT delorie DOT com I put the question to comp.std.c, and I'll be forwarding the relevant replies. One person's opinion on the "-nan" issue: In article <8ba9j6$f1k$1 AT antares DOT lu DOT erisoft DOT se>, Martin Stromberg wrote: >In the implementation of printf("%Lf\n", -nan()) for DJGPP we are >having a great dissent about whether the C99 standard requires us to >print the sign of NaNs. As they are NaNs they do not have a sign some >think. Other of us think that the sign of (or rather the bit in the >sign position in the floating point number) should be printed when >it's set. > >So supposing that X is a NaN, whatever NaN, with the sign bit set, >should printf("%Lf\n", X) print "-nan" or only "nan"? > >Must printf("%Lf\n", X) print "-nan? The intention of C99 appears to be that you should print a misleading minus sign. As I have posted before, this treatment of NaNs as signable values is in clear breach of the stated intent of IEEE 754. Unfortunately, it is not in breach of a specific requirement. However, the wording of C90 is unclear enough to permit either interpretation, so I would follow the intent of IEEE 754 rather than the intent of C99. Others will doubtless disagree. Regards, Nick Maclaren, University of Cambridge Computing Service, New Museums Site, Pembroke Street, Cambridge CB2 3QG, England. Email: nmm1 AT cam DOT ac DOT uk Tel.: +44 1223 334761 Fax: +44 1223 334679