Connecting Tech Pros Worldwide Forums | Help | Site Map

What does the standard tell about NAN?

Alexander Stippler
Guest
 
Posts: n/a
#1: Jul 22 '05
Hi,

what about "not a number"? What does the standard enforce, what not?
I read in the C standard, that NAN is defined if and only if the
implementation supports quiet NaNs for the float type.
But what about the behaviour of NaNs, e.g. comparison with 'normal' values,
operator application (+, -, *, /). Where is it defined, if at all?

regards,
alex

tom_usenet
Guest
 
Posts: n/a
#2: Jul 22 '05

re: What does the standard tell about NAN?


On Tue, 20 Jul 2004 12:08:07 +0200, Alexander Stippler
<stip@mathematik.uni-ulm.de> wrote:
[color=blue]
>Hi,
>
>what about "not a number"? What does the standard enforce, what not?
>I read in the C standard, that NAN is defined if and only if the
>implementation supports quiet NaNs for the float type.
>But what about the behaviour of NaNs, e.g. comparison with 'normal' values,
>operator application (+, -, *, /). Where is it defined, if at all?[/color]

The standard is quiet about it. However, if you have IEEE 754 floating
point, then I think all comparisons against NAN return false, but you
should read the IEEE 754 standard (or descriptions thereof) to check
this.

Note std::numeric_limits<double>::is_iec559 tells you whether the
floating point is IEEE 754 (aka IEC 559) compatible.

Tom
Brian McGuinness
Guest
 
Posts: n/a
#3: Jul 22 '05

re: What does the standard tell about NAN?


Alexander Stippler <stip@mathematik.uni-ulm.de> wrote in message news:<40fcedb5@news.uni-ulm.de>...[color=blue]
> Hi,
>
> what about "not a number"? What does the standard enforce, what not?
> I read in the C standard, that NAN is defined if and only if the
> implementation supports quiet NaNs for the float type.
> But what about the behaviour of NaNs, e.g. comparison with 'normal' values,
> operator application (+, -, *, /). Where is it defined, if at all?
>
> regards,
> alex[/color]

The NaN does not arise from the C++ standard but rather from the
IEEE 754 floating point number standard. See

http://research.microsoft.com/~holla...ieeefloat.html

--- Brian
Closed Thread