Elementi non (NAN) di un numero

Il compilatore di Visual C++ supporta i confronti non degli (NAN) elementi di un numero in modo IEEE-compiacente.se x è NAN e y non è NAN:

  • (x ! = x==) true

  • (x == x==) false

  • (y > x==) false

  • (y < x==) false

Test dell'ordine di NAN restituiscono sempre false: NAN [<, <=, >, >= []any_number] essere false.

Nel codice seguente viene illustrato come NANs in Visual C++ non può essere confrontato con correttamente in un numero a virgola mobile:

#include <math.h>
#include <stdio.h>
#include <float.h>

int main( void ) {
unsigned long nan[2]={0xffffffff, 0x7fffffff};
double g = *( double* )nan;

if ( g <= 3.0 )
   printf( "g( %g ) <= 3.0\n", g );
else if ( g > 3.0)
   printf( "g( %g ) > 3.0\n", g );
else
   printf( "g( %g ) is NaN\n", g );
}

Vedere anche

Riferimenti

Convenzioni lessicali