By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,960 Members | 2,232 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,960 IT Pros & Developers. It's quick & easy.

What does the standard tell about NAN?

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 20 Jul 2004 12:08:07 +0200, Alexander Stippler
<st**@mathematik.uni-ulm.de> wrote:
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
Jul 22 '05 #2

P: n/a
Alexander Stippler <st**@mathematik.uni-ulm.de> wrote in message news:<40******@news.uni-ulm.de>...
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/~holla...ieeefloat.html

--- Brian
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.