473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

What does the standard tell about NAN?

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
2 2759
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
5
by: Leif K-Brooks | last post by:
When StringIO gets an initial value passed to its constructor, it seems to discard it after the first call to .write(). For instance: >>> from StringIO import StringIO >>> buffer =...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
1
by: Mortel | last post by:
Hi, What I find in this product ? I want to buy this tool but I'm afraid that it's simple tool to do good application. I know that I can read about that on the internet but I want to hear what...
126
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
132
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.