In C, signbit is a macro that tests whether the sign bit of a floating-point value is set. It returns a nonzero value when the sign bit is set, and 0 otherwise.
You pass a floating value (float, double, or long double). Include <math.h>. Unlike a simple x < 0 check, signbit can detect negative zero, which still compares equal to positive zero.
Use it when the bit-level sign matters—for example when printing, classifying zeros, or copying signs with care.
Syntax
Pass the floating-point value. Start with this call.
C
signbit(-0.0);
Call
What it does
signbit(-0.0);
Returns nonzero because the sign bit of negative zero is set.
Include <math.h>. signbit is a type-generic macro, not a single function with one fixed signature.
Library declarations
C
int signbit(real-floating x);
Parameters
Parameter
Description
x
Required. A floating value whose sign bit you want to test.
Return Value
Return Value
Description
Nonzero
The sign bit is set (negative number or negative zero).