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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms