abs(3)

abs3

Return absolute value for integer types

Usage

Standard C Library (libc, -lc)

#include <stdlib.h>

int

abs(int i);

long

labs(long i);

long long

llabs(long long i);

#include <inttypes.h>

intmax_t

imaxabs(intmax_t i);

Overview

The abs(), labs(), llabs(), and imaxabs() functions compute the absolute value of i.

Return values

The abs(), labs(), llabs(), and imaxabs() functions return the absolute value.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 47 times.

  1. 2.0.5–2.1.7.1
  2. 2.2.2–2.2.8
  3. 2.2.9
  4. 3.0–3.2
  5. 3.3
  6. 3.4
  7. 3.5–3.5.1
  8. 4.0
  9. 4.1–4.2
  10. 4.3–4.4
  11. 4.5–4.11
  12. 5.0
  13. 5.1–6.3
  14. 6.4
  15. 7.0
  16. 7.1
  17. 7.2
  18. 7.3
  19. 7.4
  20. 8.0
  21. 8.1
  22. 8.2
  23. 8.3
  24. 8.4
  25. 9.0
  26. 9.1
  27. 9.2
  28. 9.3
  29. 10.0
  30. 10.1
  31. 10.2
  32. 10.3
  33. 10.4
  34. 11.0
  35. 11.1
  36. 11.2
  37. 11.3
  38. 11.4
  39. 12.0
  40. 12.1
  41. 12.2
  42. 12.3
  43. 12.4
  44. 13.0–13.1
  45. 13.2
  46. 13.3–14.5
  47. 15.0–15.1
  48. 16.0

Standards

The abs(), labs(), llabs(), and imaxabs() functions conform to ISO/IEC 9899:2024 (“ISO C23”) and IEEE Std 1003.1-2024 (“POSIX.1”).

History

The abs() function first appeared in Version 6 AT&T UNIX. The labs() function first appeared in 4.3BSD. The llabs() and imaxabs() functions first appeared in FreeBSD 5.0.

Bugs

The absolute value of the most negative integer remains negative.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.