ABS(3POSIX)
π ABS(3POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual β¨ this little page lives in the 3POSIX section, and it's all about abs() β yes, the absolute value girly. she's simple, she's iconic, she's been holding down the math since forever. π
πΈ PROLOG πΈ
okay so first things first, this manual page is part of the POSIX Programmer's Manual. that means:
the Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. π
so like, don't come for me if Linux does its own thing. check the Linux page. that's the vibe check. π¦
β¨ NAME β¨
abs β return an integer absolute value
that's it. that's the whole job. no cap. π
π§ SYNOPSIS π§
#include <stdlib.h>
int abs(int i);
look at her. one include, one function, one int. clean. minimal. main character energy. π
π DESCRIPTION π
so here's the tea: the functionality described on this reference page is aligned with the ISO C standard. if anything here conflicts with the requirements described in the ISO C standard, that conflict is unintentional β it's not on purpose, bestie. this volume of POSIX.1β2017 defers to the ISO C standard. periodt. π
now the actual function:
the abs() function shall compute the absolute value of its integer operand, i.
and here's the part you need to hear: if the result cannot be represented, the behavior is undefined. π like, undefined. not "we'll figure it out", not "it'll probably be fine". undefined. tread carefully. π
π RETURN VALUE π
the abs() function shall return the absolute value of its integer operand. that's it. she gives you back a number, and that number is the non-negative version. slay. β¨
π ERRORS π
no errors are defined.
genuinely. none. she doesn't do errors. πΈ
the following sections are informative β so like, heads up, the stuff coming up is the informative-flavored part of the page, not the normative requirements. iykyk. π
π EXAMPLES π
none.
(yeah. zero. she's so self-explanatory she didn't even bring examples to the function. respect.) π
π¦ APPLICATION USAGE π¦
okay this one's actually important, bestie, listen up:
in two's-complement representation, the absolute value of the negative integer with largest magnitude {INT_MIN} might not be representable. π
so like, {INT_MIN} is out here being the most negative possible int, and her absolute value is... a little too much for the representation to hold. it's giving overflow. it's giving "cannot be represented." just be aware. π
β RATIONALE β
none.
no reasoning needed. she simply is. π
π₯ FUTURE DIRECTIONS π₯
none.
she's not going anywhere and she's not changing. stability icon. π
π« SEE ALSO π«
fabs()labs()
the Base Definitions volume of POSIX.1β2017, <stdlib.h>
like, if you need the floating-point one, that's fabs(). if you need the long one, that's labs(). abs() is the plain int girly. know your family tree. π«Ά
π COPYRIGHT π
okay the legal part, don't skip it, it's still real:
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.
in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. π
the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π this was IEEE/The Open Group, 2017, signing off from the ABS(3POSIX) corner of the manual. go compute some absolute values, stay representable, and don't let {INT_MIN} catch you slipping. πβ¨ππ¦πΈπ
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms