Thanks! (I thought that the only way to obtain a C99 standard was to
pay $$$ - that's the way most standards are.)
Just reviewed in this specification a couple of points of recent
interest (to me) - there are an amazing number of logical states that
are not specified. For instance, the behavior of log() says:
Description
2 The log functions compute the base-e (natural) logarithm of x.
A domain error occurs if the argument is negative. A range error may
occur
if the argument is zero.
Returns
3 The logfunctions return loge(x).
And what does it return if there there is a domain error, which could
occur
with half the possible values for x? It certainly cannot return
loge() in these cases, as described, since that is mathematically
undefined. The answer must be "implementation defined", conceivably
even an apparently valid result, like "5.0" (which is no more right
nor wrong than -HUGE_VAL) so long as it set the domain error. This
omission is presumably because implementations do not have to support
NaN or Inf (5.2.4.2.2-3). However, since most do, and the
specification says what these are in C99, would it have killed the
standard's writers to have changed the log() return spec to describe
what happens in that case? To something like (second sentence added):
Returns
3 The log function normally returns loge(x). If a domain error
occurs it returns NAN if implementation supported, else returns -
HUGE_VAL.
and in section 7.12.1-2, make the more general change for all
functions:
On a domain error, the function returns an implementation-
deï¬ned value;
to
On a domain error, the function returns NAN if implementation
supported, else the value specified by this standard.
?
For that matter, Solaris supports quiet and signaling nan, C99 does
not. C99 defines bits for NAN, which is a quiet NAN, but doesn't do
anything about the signaling type, F.2.1-1 says "This speciï¬cation
does not deï¬ne the behavior of signaling NaNs."
As for printing -0 as "-0". That is in notes 242 and 282 (page 276
and 350) which annotate the "+" modifier:
The results of all floating conversions of a negative zero, and of
negative values that round to zero, include a minus sign.
Which I would argue was the wrong choice (but that horse has left the
barn), since a printed -0 is not the desired result in any physical
measurement or quantization. Discriminating between +0 and -0 is only
of interest to a programmer - it is the sort of special case usually
handled by a macro like
isnormal().
Regards,
David Mathog