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

#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