What does the standard tell about NAN?

A

Alexander Stippler

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
 
T

tom_usenet

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?

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
 
B

Brian McGuinness

Alexander Stippler said:
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

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

http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html

--- Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top