C programming math.h isnormal

In C programming the <math.h> isnormal() function determine if the argument is ‘normal’.The floating point type value,integer value and character are considered as ‘normal’.The remaining type:NaN,infinity,Zero,subnormal are treated as not normal.

bool isnormal(float x);
bool isnormal(double x);
bool isnormal(long double x);

x -A floating point value.

Return type
bool -Returns true if it is normal else 0.

All the three functions given above are same.The only difference is in their parameter type.

Code example

printf( “%i” , isfinite( 123.34 ) );
printf( “%i” , isfinite( NAN ) );

Output in Code::Blocks,



Some points to note

i)The function will determine the argument base on the specific semantic types.This means if the argument passed is wider than it’s semantic type than it is converted to it’s semantic type and the determination is based on that type.To understand what this means consider that we are passing a very large number -not representable by any floating point type-in this case the argument type cannot represent the value so here the argument is treated as ‘infinite’ value and the function returns false signifying that the argument is not finite.A code example is given below.

Code example

printf( “%i” , isnormal( 2e200 ) );

printf( “%i” , isnormal( 2e350 ) );

printf( “%i” , isnormal( INFINITE ) );