Mail Archives: djgpp-workers/2000/03/27/03:21:22
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 <eplmst AT lu DOT erisoft DOT se> 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
- Raw text -