In C programming the <math.h> signbit() function determine if the ‘sign‘ of the argument is negative.The declaration of the ‘signbit’ functions are given below.
|bool signbit(float x);|
|bool signbit(double x);|
|bool signbit(long double x);|
x -A floating point value whose sign is to be determined.
bool -Returns true if the sign is negative.
All the three functions are the same.The only difference between than is the type of argument accepted by the function.
The sign determination is not limited to only normal values(integer and floating point value) but it can also determine the sign of NaN,infinity,subnormal,0.It can determine the sign of all types of values.
printf( “%i”, signbit( d1 ) );
printf( “\n%i”, signbit( d2 ) );
printf( “\n%i”, signbit( -0.0 ) );
printf( “\n%i”, signbit( -INFINITY ) );
‘INFINITY’ is the macro that represent the infinite value.