ACOS(3POSIX)
π ACOS β arc cosine, but make it a vibe π
okay bestie, so this one is ACOS(3POSIX) from the POSIX Programmer's Manual, and before we even get into it, there's some housekeeping.
β¨ PROLOG β¨
So like, this manual page is part of the POSIX Programmer's Manual. But heads up: the Linux implementation of this interface may differ β so if you're on Linux, go consult the corresponding Linux manual page for the actual tea. Or honestly, the interface might just not be implemented on Linux at all. Rude, but okay. π«
πΈ NAME πΈ
acos, acosf, acosl β arc cosine functions. That's the whole squad. Three of them. All doing arc cosine, just in different flavors. π
π¦ SYNOPSIS π¦
#include <math.h>
double acos(double x);
float acosf(float x);
long double acosl(long double x);
Look at that. Gorgeous. Three functions, one header, zero drama. β¨
π DESCRIPTION π
Okay so real talk: everything described on this reference page is aligned with the ISO C standard. And if there's any conflict between what's written here and the ISO C standard? That was not intentional, bestie. This volume of POSIX.1-2017 fully defers to the ISO C standard. ISO C is the main character here, we're just supporting cast. π
So what do these functions actually do? They compute the principal value of the arc cosine of their argument x. And the value of x should be in the range [-1,1]. That's the vibe check. Stay in range.
Now β if you're the type of application that wants to actually check for error situations (responsible queen behavior, honestly), here's the ritual:
- set
errnoto zero - call
feclearexcept(FE_ALL_EXCEPT) - then call these functions
And when they come back? If errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero β an error has occurred. No cap. π€
π₯ RETURN VALUE π₯
Upon successful completion, these functions shall return the arc cosine of x, in the range [0,Ο] radians. Slay. β¨
Now the messy parts, and yes we're covering all of them:
- For finite values of
xthat are not in the range[-1,1], a domain error shall occur, and either aNaN(if supported) or an implementation-defined value shall be returned. Like, pick one, it's your call, but it's happening. - If
xisNaN, aNaNshall be returned. Fair. Consistent. Iconic. - If
xis+1,+0shall be returned. Cute. π - If
xisΒ±Inf, a domain error shall occur, and aNaNshall be returned.
π ERRORS π
These functions shall fail if:
- Domain Error β the
xargument is finite and is not in the range[-1,1], or isΒ±Inf.
And then it splits depending on your setup:
- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[EDOM]. - If the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the invalid floating-point exception shall be raised.
The following sections are informative. So like, they're extra credit. Still reading them tho because I love you. π«Ά
π EXAMPLES π
None. π Not a single example. We get nothing. Moving on.
π APPLICATION USAGE π
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other β like, they don't text each other, they don't coordinate. But at least one of them must be non-zero. That's the rule. Periodt.
π§ RATIONALE π§
None. π
β FUTURE DIRECTIONS β
None. π
π SEE ALSO π
cos()feclearexcept()fetestexcept()isnan()
Also the Base Definitions volume of POSIX.1-2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, and <math.h>. Go read them, bestie, they're all connected. π
π COPYRIGHT π
Okay so legally I have to say all of this and I'm saying it exactly, no edits:
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 from IEEE/The Open Group, dated 2017, filed under ACOS(3POSIX). Now go compute some arc cosine, stay in [-1,1], and hydrate. πβ¨π¦
π¦ 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