C examples for math.h:signbit
Item | Value |
---|---|
type | macro/function |
<cmath> <ctgmath> <math.h>
Returns whether the sign of x is negative.
bool signbit (float x); bool signbit (double x); bool signbit (long double x); signbit(x)//macro
Parameter | Description |
---|---|
x | A floating-point value. |
A non-zero value (true) if the sign of x is negative; and zero (false) otherwise.
#include <stdio.h> #include <math.h> /* signbit, sqrt */ int main()/* w ww. j a v a2 s . c om*/ { int a = 0; printf ("%d\n",signbit(0.0)); printf ("%d\n",signbit(1.0/a)); printf ("%d\n",signbit(-1.0/a)); printf ("%d\n",signbit(sqrt(-1.0))); return 0; }