signbit(3)
π signbit(3) β test sign of a real floating-point number
okay bestie, welcome to signbit(3) β¨ this one lives in the Library Functions Manual and it's genuinely so underrated. it does exactly one thing and it does it flawlessly. let's get into it π«Ά
πΈ NAME πΈ
signbit β test sign of a real floating-point number
periodt. that's the whole job description. no notes. π
π LIBRARY π
Math library (libm, -lm)
so yeah, you gotta link it: -lm. don't forget her, or the linker will be giving major side-eye π
β¨ SYNOPSIS β¨
#include <math.h>
int signbit(x);
π Feature Test Macro Requirements for glibc (see feature_test_macros(7)): π
signbit():_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
like, define the right macro or glibc will pretend she doesn't know you π iykyk
π DESCRIPTION π
signbit() is a generic macro which can work on all real floating-point types. she's flexible like that π
she returns a nonzero value if the value of x has its sign bit set.
okay now this part is IMPORTANT, do not skip, this is the main character twist π
This is not the same as x < 0.0, because IEEE 754 floating point allows zero to be signed. The comparison -0.0 < 0.0 is false, but signbit(-0.0) will return a nonzero value.
like... -0.0 is out here pretending to be zero and signbit() is the only one who sees through the act. iconic behavior honestly π₯
NaNs and infinities have a sign bit. yes, even your chaotic NaN has a sign bit. everyone's got layers bestie π
β RETURN VALUE β
The signbit() macro returns nonzero if the sign of x is negative; otherwise, it returns zero.
that's it. that's the tea. binary queen π
π ERRORS π
No errors occur.
literally none. zero drama. the calmest function on the whole system call list π§ββοΈβ¨
π¦ ATTRIBUTES π¦
For an explanation of the terms used in this section, see attributes(7).
- Interface:
signbit()- Attribute: Thread safety
- Value:
MT-Safe
so she's MT-Safe β thread safe, no cap. run her from every thread you've got, she's not fazed πͺ
π STANDARDS π
C11, POSIX.1-2008.
certified, official, government-approved slay πβ¨
π°οΈ HISTORY π°οΈ
POSIX.1-2001, C99.
This function is defined in IEC 559 (and the appendix with recommended functions in IEEE 754/IEEE 854).
she's been around since 2001 and honestly? aging like fine wine π·π
π SEE ALSO π
go read her right now, they're besties fr fr π
and that's the whole page bestie!! you now officially understand signbit(3) better than 90% of people who use it π remember: -0.0 is real, x < 0.0 will lie to you, and signbit() never will. go forth and check them sign bits πΈ
mwah π this has been signbit(3) from Linux man-pages 6.20, dated 2026-02-08 β sourced straight from the manual, rewritten with love, zero facts harmed in the making of this page πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: GPL-1.0-or-later
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms