Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > UNIX's int isnan(double x) routine for Windows/Visual C/C++ 6.0 ?

Reply
Thread Tools

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

 
 
Skybuck Flying
Guest
Posts: n/a
 
      07-05-2004
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


 
Reply With Quote
 
 
 
 
Russell Hanneken
Guest
Posts: n/a
 
      07-05-2004
Skybuck Flying wrote:
>
> 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/bchambl...me_to_clc.html

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

--
Russell Hanneken
http://www.velocityreviews.com/forums/(E-Mail Removed)
Use ROT13 to decode my email address.



 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      07-06-2004
"Russell Hanneken" <(E-Mail Removed)> wrote:

> Skybuck Flying wrote:
> >
> > 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.


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

Richard
 
Reply With Quote
 
Gregory Pietsch
Guest
Posts: n/a
 
      07-16-2004
"Skybuck Flying" <(E-Mail Removed)> wrote in message news:<cccg0k$gi2$(E-Mail Removed)1.nb.home.nl>...
> 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
 
Reply With Quote
 
kal
Guest
Posts: n/a
 
      07-16-2004
"Skybuck Flying" <(E-Mail Removed)> wrote in message news:<cccg0k$gi2$(E-Mail Removed)1.nb.home.nl>...

> 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>
 
Reply With Quote
 
one2001boy@yahoo.com
Guest
Posts: n/a
 
      07-17-2004
Gregory Pietsch wrote:
> "Skybuck Flying" <(E-Mail Removed)> wrote in message news:<cccg0k$gi2$(E-Mail Removed)1.nb.home.nl>...
>
>>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 ?


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.

>>
>>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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why is int a[0] not allowed, but int* a = new int[0] is? haijin.biz@gmail.com C++ 9 04-17-2007 09:01 AM
Difference between int i, j; and int i; int j; arun C Programming 8 07-31-2006 05:11 AM
int a[10]; int* p=(int*)((&a)+1); But why p isn't equal to ((&a)+1)? aling C++ 8 10-20-2005 02:42 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments