FABS(3POSIX)
π FABS(3POSIX) π
okay bestie, so this one lives in the POSIX Programmer's Manual β that's the manual name, and the whole page is literally called FABS(3POSIX). it's about fabs and its two glow-up siblings fabsf and fabsl, aka the absolute value girlies. let's get into it π
β¨ PROLOG β¨
so like, real talk first: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β so if something looks off, go consult the corresponding Linux manual page for the deets on Linux behavior. OR the interface might not even be implemented on Linux at all. no cap. π
πΈ NAME πΈ
fabs, fabsf, fabsl β absolute value function π
π¦ SYNOPSIS π¦
#include <math.h>
double fabs(double x);
float fabsf(float x);
long double fabsl(long double x);
three of them. one for each float size. they're a trio, they're iconic, they ate. π
π DESCRIPTION π
so here's the thing β the functionality described on this reference page is aligned with the ISO C standard. if there's any conflict between what's written here and the ISO C standard? that's unintentional, not a plot twist. this volume of POSIX.1β2017 defers to the ISO C standard. periodt.
these functions shall compute the absolute value of their argument x, written as |x|. that's it. that's the whole job. take the negative away, it's giving positive main character energy β¨
π RETURN VALUE π
- upon successful completion, these functions shall return the absolute value of
xπ - if
xis NaN, a NaN shall be returned π - if
xis Β±0,+0shall be returned β - if
xis Β±Inf,+Infshall be returned π₯
π ERRORS π
no errors are defined. nothing to see here, it's a clean run bestie π§
heads up: the following sections are informative β so they're the fun bonus lore, not the hard requirements.
π EXAMPLES π
πΈ Computing the 1-Norm of a Floating-Point Vector πΈ
this example shows the use of fabs() to compute the 1-norm of a vector, defined like this:
norm1(v) = |v[0]| + |v[1]| + ... + |v[n-1]|
where |x| denotes the absolute value of x, n denotes the vector's dimension, and v[i] denotes the i-th component of v (0β€i<n).
#include <math.h>
double
norm1(const double v[], const int n)
{
int i;
double n1_v; /* 1-norm of v */
n1_v = 0;
for (i=0; i<n; i++) {
n1_v += fabs (v[i]);
}
return n1_v;
}
look at that loop. it's just vibes and addition. obsessed π
π APPLICATION USAGE π
none. literally nothing. empty. the void. π«Ά
π RATIONALE π
none. also nothing. we love a low-effort section that still gets to exist π
π¦ FUTURE DIRECTIONS π¦
none. the future is unwritten and this section is blank, bestie β¨
π₯ SEE ALSO π₯
isnan()- the Base Definitions volume of POSIX.1β2017,
<math.h>
π COPYRIGHT π
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 one came to you courtesy of IEEE/The Open Group, 2017 β the FABS(3POSIX) page, signing off. take the absolute value of your day and slay πβ¨π
π¦ 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