Re: valid numbers

New Message Reply Date view Thread view Subject view Author view

Marcus Barnes (marcus++at++multigen.com)
Thu, 27 Mar 1997 13:28:24 -0800


On Mar 27, 8:11am, Bryan Wasileski wrote:
>
> I need to verify whether or not position and orientation data is valid;
> valid in the sense of being a valid number. Sometimes I receive data
> (via ethernet packets) that is NaN, "not a numer" and I need to make sure
> that it IS a valid floating point number before using it. Are there any
> routines already available that check for valid floating point
> representation?

You can learn about IEEE 754 Binary Floating-point Arithmetic from the math(3)
manual page. Also on IRIX 6.2 look at man isnan(3).

The tests you can use in your code are:

#include <math.h>
{
   float nan = HUGE_VAL + __infinity; /* like this to be NaN */

   if ( nan != nan ) printf( "found a NaN using !=" );
   if ( isnan( nan ) printf( "found a NaN using isnan()" );
}

Regards.

--
+ Marcus Barnes, Technical Staff        mailto:marcus++at++multigen.com +
+ Multigen Inc.                         http://www.multigen.com    +
+ 550 S. Winchester Blvd.               phoneto:1-408-556-2654     +
+ Suite 500 San Jose CA 95128           faxto:1-408-261-4102       +
=======================================================================
List Archives, FAQ, FTP:  http://www.sgi.com/Technology/Performer/
            Submissions:  info-performer++at++sgi.com
        Admin. requests:  info-performer-request++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:58 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.