signbit

Header: <math.h>

Determines if the given floating-point number arg is negative. The macro returns an integral value.

# Declarations

#define signbit( arg ) /* implementation defined */

(since C99)

# Parameters

# Return value

Nonzero integral value if arg is negative, 0 otherwise.

# Notes

This macro detects the sign bit of zeroes, infinities, and NaNs. Along with copysign, this macro is one of the only two portable ways to examine the sign of a NaN.

# Example

#include <math.h>
#include <stdio.h>
 
int main(void)
{
    printf("signbit(+0.0) = %d\n", signbit(+0.0));
    printf("signbit(-0.0) = %d\n", signbit(-0.0));
}

# See also