ATAN(3POSIX)

πŸ¦‹ ATAN β€” the POSIX Programmer's Manual page, bestie edition πŸ’–

okay so quick vibe check before we even start: this one lives in the POSIX Programmer's Manual. That's the manual name, that's the whole set, and it's iconic.


✨ PROLOG ✨

so like, real talk πŸ’… this manual page is part of the POSIX Programmer's Manual. That means: the Linux implementation of this interface may differ β€” so if you're on Linux, go consult the corresponding Linux manual page for the details of Linux behavior β€” or the interface may not even be implemented on Linux at all. no cap, that's just how it is πŸ™ˆ


πŸŽ€ NAME πŸŽ€

atan, atanf, atanl β€” arc tangent function. that's it, that's the whole name section, she's brief and she's slaying ✨


🌸 SYNOPSIS 🌸

#include <math.h>

double atan(double x);
float atanf(float x);
long double atanl(long double x);

three sisters, three types, one job 🫢


πŸ’œ DESCRIPTION πŸ’œ

so the functionality described on this reference page is aligned with the ISO C standard. and if there's any conflict between the requirements described here and the ISO C standard β€” that's unintentional, bestie, nobody did that on purpose 😭. This volume of POSIX.1‐2017 defers to the ISO C standard. periodt.

These functions shall compute the principal value of the arc tangent of their argument x. that's the assignment. that's the whole assignment πŸ’…

now β€” if your application wants to check for error situations (and she's a thorough queen so maybe you do ✨), here's the ritual:

  • set errno to zero
  • call feclearexcept(FE_ALL_EXCEPT)
  • before calling these functions

then on return, if errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero β€” an error has occurred. that's the signal, that's the tea πŸ“


πŸ‘‘ RETURN VALUE πŸ‘‘

Upon successful completion, these functions shall return the arc tangent of x in the range [-Ο€/2,Ο€/2] radians. cute range, love that for her 🌈

here's the whole rundown, no skipping:

  • If x is NaN, a NaN shall be returned.
  • If x is Β±0, x shall be returned. (she returns herself. self-love πŸ’…)
  • If x is Β±Inf, Β±Ο€/2 shall be returned.
  • If x is subnormal, a range error may occur and x should be returned.
  • If x is not returned, atan(), atanf(), and atanl() shall return an implementation-defined value no greater in magnitude than DBL_MIN, FLT_MIN, and LDBL_MIN, respectively.

πŸ”₯ ERRORS πŸ”₯

These functions may fail if:

  • Range Error β€” The value of x is subnormal.
    • If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE].
    • If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow floating-point exception shall be raised.
The following sections are informative. 🫢 so like, the vibes are advisory from here on out, bestie.

🧚 EXAMPLES 🧚

None. literally none. she said "figure it out, you're smart" πŸ˜­πŸ’€


⭐ APPLICATION USAGE ⭐

On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other β€” they don't text each other, they don't coordinate, nothing β€” but at least one of them must be non-zero. that's the rule. respect it 🌸


πŸŽ€ RATIONALE πŸŽ€

None. the reasoning section is empty because the reasoning is self-evident, bestie ✨


πŸ¦‹ FUTURE DIRECTIONS πŸ¦‹

None. the future is unwritten and also this function is not changing πŸ’œ


🌈 SEE ALSO 🌈

  • atan2()
  • feclearexcept()
  • fetestexcept()
  • isnan()
  • tan()

and also, from The Base Definitions volume of POSIX.1‐2017:

  • Section 4.20, Treatment of Error Conditions for Mathematical Functions
  • <math.h>

go read those, iykyk πŸ“šβœ¨


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 .


okay bestie that's the whole page, we ate and left no crumbs πŸ‘‘

signing off with the official receipts: IEEE/The Open Group, 2017, and this page's name in the manual is ATAN(3POSIX) πŸ’…βœ¨πŸŽ€πŸ¦‹