abs(3)

✨ abs(3) β€” the absolute value glow-up ✨

okay bestie, gather round, because today we're talking about abs(3), a.k.a. the girl who takes a negative integer and makes it positive, no drama, no questions asked. πŸ’… This one lives in the Library Functions Manual section, and she's part of the Standard C library (libc, -lc). 🫢


🌸 NAME 🌸

abs, labs, llabs, imaxabs, uabs, ulabs, ullabs, umaxabs β€” compute the absolute value of an integer πŸ’–

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) β€” the moment you link this, it's over for everyone. ✨

🌈 SYNOPSIS 🌈

#include <stdlib.h>

int abs(int j);
long labs(long j);
long long llabs(long long j);

unsigned int uabs(int j);
unsigned long ulabs(long j);
unsigned long long ullabs(long long j);

#include <inttypes.h>

intmax_t imaxabs(intmax_t j);
uintmax_t umaxabs(intmax_t j);

πŸŽ€ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): πŸŽ€

okay so glibc is picky, she has requirements, respect them:

  • llabs():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
  • uabs(), ulabs(), ullabs(), umaxabs():
_ISOC2Y_SOURCE

πŸ’– DESCRIPTION πŸ’–

These functions compute the absolute value of the argument j of the appropriate integer type for the function. That's it. That's the whole job. No cap. 🌟

Like β€” you hand them an integer, they hand you back how far it is from zero, always in a happy positive direction. If j is already positive, nothing changes, she's already slaying. If j is negative, the sign gets dropped like a toxic ex. πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

Returns the absolute value of the integer argument, of the appropriate integer type for the function. Iconic behaviour honestly. πŸ‘‘


πŸ¦‹ ATTRIBUTES πŸ¦‹

For an explanation of the terms used in this section, see attributes(7). Here's the vibe check, laid out flat since we don't do tables around here:

  • Interface: abs(), labs(), llabs(), imaxabs(), uabs(), ulabs(), ullabs(), umaxabs() β€” Attribute: Thread safety β€” Value: MT-Safe βœ…

(translation: she's thread safe, all of her, every single one, multi-thread approved, no notes)


🌟 STANDARDS 🌟

these girls made it official:

  • abs()
  • labs()
  • llabs()
  • imaxabs()

β€” all of them: C23, POSIX.1-2024 πŸ“œβœ¨


πŸ•°οΈ HISTORY πŸ•°οΈ

the lore, chronologically, because we love a backstory:

  • abs() β€” C89, POSIX.1-1996, SVr4, 4.3BSD.
  • labs() β€” C89, POSIX.1-2001.
  • llabs() β€” C99, POSIX.1-2001; glibc 2.0.
  • imaxabs() β€” C99, POSIX.1-2001; glibc 2.1.1.
  • uabs(), ulabs(), ullabs() β€” C2y; glibc 2.42.
  • umaxabs() β€” C2y; glibc 2.43.

the unsigned girlies are the new new, freshly debuted in C2y, we're obsessed. πŸ’œ


πŸ’€ BUGS πŸ’€

For abs(), labs(), llabs(), and imaxabs(), trying to take the absolute value of the most negative integer is not defined.

bestie this is the trap. 😭 like, the most negative integer of a signed type has no matching positive counterpart, and the math just does not work. There is no answer. The standard says "not defined" and walks away. Do not do this. Do not pass go. Not me finding this out in production. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€

cabs(3), ceil(3), fabs(3), floor(3), rint(3) β€” the rest of the math girlies, go say hi. πŸŽ€


and that's the whole page, bestie β€” this was Linux man-pages 6.20, dated 2026-02-08, brought to you by abs(3) and her entire extended family of absolute value functions. go take the absolute value of something and feel amazing about it. mwah. πŸ’‹βœ¨

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