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 π
Forabs(),labs(),llabs(), andimaxabs(), 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
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms