isunordered


isunordered

Tests whether two floating-point values can be numerically ordered

 #include <math.h> int isunordered( x, y ) 

The macro isunordered( ) tests whether any ordered relation exists between two floating-point values, without risking an "invalid operand" exception in case either of them is NaN ("not a number"). Both operands must have real floating-point types. Two floating-point values are be said to be ordered if one is either less than, equal to, or greater than the other. If either or both of them are NaN, then they are unordered. isunordered( ) returns a nonzero value (that is, TRue) if no ordered relation obtains between the two arguments.

Example

 double maximum( double a, double b ) {   if ( isinf( a ) )         // +Inf > anything; -Inf < anything     return ( signbit( a ) ? b : a );   if ( isinf( b ) )     return ( signbit( b ) ? a : b );   if ( isunordered( a, b ) )   {     feraiseexcept( FE_INVALID );     return NAN;   }   return ( a > b ? a : b ); } 

See Also

isgreater( ), isgreaterequal( ), isless( ), islessequal( ), islessgreater( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net