signbit - C math.h

C examples for math.h:signbit

Summary

Item Value
type macro/function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns whether the sign of x is negative.

Prototype

bool signbit (float x);
bool signbit (double x);
bool signbit (long double x);
     signbit(x)//macro

Parameters

Parameter Description
x A floating-point value.

Return value

A non-zero value (true) if the sign of x is negative; and zero (false) otherwise.

Demo Code


#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;
}

Related Tutorials