6.11.166 signbit Macro
Returns true if its argument is negative.
Include
<math.h>
Prototype
int signbit(floating-point
x);
Argument
x
- any floating-point number
Return Value
Returns true if its argument is negative; false otherwise.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x, y, z;
int s;
x = -5.0;
y = 3.0;
z = x / y;
s = signbit(z);
printf("The result of the division of %f by %f is %s\n", x, y, s ? "negative" : "positive");
}
Example Output
The result of the division of -5.000000 by 3.000000 is negative