UNIX's int isnan(double x) routine for Windows/Visual C/C++ 6.0 ?

S

Skybuck Flying

Hi,

I have one more remaining "problem" with compiling a unix source code for
windows/visual c/c++ 6.0

What does the isnan routine do ?

Documentation says it checks for NaN ? What does that mean ?

What is a good replacement for Visual C/C++ 6.0 ?

Bye,
Skybuck
 
R

Russell Hanneken

Skybuck said:
What does the isnan routine do ?

Documentation says it checks for NaN ? What does that mean ?

As I understand it:

The IEEE 754-1985 standard defines ways of representing floating point
values as binary numbers. One bit-pattern called NaN ("not a number") is a
special case; it is used to represent values that don't have a valid
representation in the IEEE format (for example, square root of a negative
number).

Many (but not all) implementations of C abide by the IEEE standard for
representing floating point numbers.

The Single Unix Specification defines the C function isnan. You pass it a
double, and it tells you if the value is NaN (i.e., it returns a nonzero
value if the parameter is NaN, 0 if it is not). (For systems that have the
isnan function but don't support NaN values, isnan always returns 0.)
What is a good replacement for Visual C/C++ 6.0 ?

The Microsoft C library seems to have a function called _isnan (note the
leading underscore) that works like the Unix function isnan. However, it is
declared in the header <float.h> instead of <math.h>.

Anyway, that's my understanding. I'm not an expert on these issues. IEEE
754-1985, the Single Unix Specification, and Microsoft C implementation are
off-topic for this newsgroup. See the welcome message:

http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html

If you want more information, you'd be better off directing your queries to
another newsgroup.
 
R

Richard Bos

Russell Hanneken said:
As I understand it:

The IEEE 754-1985 standard defines ways of representing floating point
values as binary numbers. One bit-pattern called NaN ("not a number") is a
special case; it is used to represent values that don't have a valid
representation in the IEEE format (for example, square root of a negative
number).

Many (but not all) implementations of C abide by the IEEE standard for
representing floating point numbers.

The Single Unix Specification defines the C function isnan.

More on-topic, C99 defines a macro with that name, with the expected
semantics. This may not be useful for VC 6.0.

Richard
 
G

Gregory Pietsch

Skybuck Flying said:
Hi,

I have one more remaining "problem" with compiling a unix source code for
windows/visual c/c++ 6.0

What does the isnan routine do ?

Documentation says it checks for NaN ? What does that mean ?

What is a good replacement for Visual C/C++ 6.0 ?

Bye,
Skybuck

In C99, the isnan() macro, defined in <math.h>, is nonzero if its
argument is a NaN (not-a-number).

Floating-point numbers can be classified into one of the following
categories: normal nonzero numbers, subnormal nonzero numbers, zero,
infinity, and not-a-numbers (bit sequences that do not represent any
number).

One way of representing the macro in C99 is:

#define isnan(_X) (fpclassify(_X)==FP_NAN)

It would be nice if M$ provided a C99-compatible <math.h> that had a
C99-compatible fpclassify() macro and FP_NAN for the above to make
sense.

Gregory Pietsch
 
K

kal

Skybuck Flying said:
What does the isnan routine do ?

Documentation says it checks for NaN ? What does that mean ?

What is a good replacement for Visual C/C++ 6.0 ?

Try "_isnan" function declared in <float.h>
 
O

one2001boy

C/C++ interpreter Ch has a good support for C99 complex, IEEE-754
floating-point arithmetic, generic mathematical functions, VLA etc.
It works in windows, linux, solaris, HP-UX, MacOSX and FreeBSD.

You can google search to find it.
 

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
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top