Part1 - Part2 - Part3 - Part4 - Part5 - Single Page

Top Document: comp.unix.aix Frequently Asked Questions (Part 4 of 5)
Previous Document: 3.02: How do I statically bind Fortran libraries and dynamically bind C libraries?
Next Document: 3.04: Some info sources on IEEE floating point.


[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]

3.03: How do I check if a number is NaN?



NaN is "Not a Number".  It arises because the RISC System/6000 uses
IEEE floating point arithmetic.

To determine if a variable is a NaN you can make use of the property
that a NaN does not compare equal to anything, including itself.
Thus, for real variable X, use

	IF (X .NE. X) THEN	! this will be true if X is NaN

Floating point operations which cause exceptions (such as an overflow)
cause status bits to be set in the Floating Point Status and Control
Register (FPSCR).  There is a Fortran interface to query the FPSCR, and
it is described in the XLF Fortran manuals -- I don't have the manuals
right here, but look for FPGETS and FPSETS.

The IBM manual "Risc System/6000 Hardware Technical Reference - General
Information" (SA23-2643) describes what floating point exceptions can
occur and which bits are set in the FPSCR as a result of those exceptions.




Top Document: comp.unix.aix Frequently Asked Questions (Part 4 of 5)
Previous Document: 3.02: How do I statically bind Fortran libraries and dynamically bind C libraries?
Next Document: 3.04: Some info sources on IEEE floating point.

Part1 - Part2 - Part3 - Part4 - Part5 - Single Page


[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
bofh@mail.teleweb.pt (Jose Pina Coelho)

Last Update May 13 2007 @ 00:21 AM