SIN(3POSIX)
πΈ SIN(3POSIX) β the POSIX Programmer's Manual, but make it a group chat πΈ
okay bestie, welcome to SIN(3POSIX), straight out of the POSIX Programmer's Manual. this is the sine function and she is iconic. buckle up π
β οΈ PROLOG (read this first, fr)
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 pls consult the corresponding Linux manual page for the deets on Linux behavior. or, plot twist, the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
sin, sinf, sinl β the sine function π¦
π SYNOPSIS π
#include <math.h>
double sin(double x);
float sinf(float x);
long double sinl(long double x);
π DESCRIPTION π
the functionality 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's unintentional, no cap. this volume of POSIX.1β2017 defers to the ISO C standard, periodt.
these functions shall compute the sine of their argument x, and x is measured in radians btw (not degrees, bestie, do not come at me with degrees).
ok so if your app wants to actually check for error situations, here's the vibe check you gotta do: set errno to zero and 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. π
β RETURN VALUE β
upon successful completion, these functions shall return the sine of x. slay.
- if
xisNaN, aNaNshall be returned. (garbage in, garbage out, but make it β¨formalβ¨) - if
xisΒ±0,xshall be returned. (zero is zero, she's consistent) - if
xis subnormal, a range error may occur andxshould be returned. - if
xis not returned,sin(),sinf(), andsinl()shall return an implementation-defined value no greater in magnitude thanDBL_MIN,FLT_MIN, andLDBL_MIN, respectively. - if
xisΒ±Inf, a domain error shall occur, and aNaNshall be returned. π¨
π ERRORS π
these functions shall fail if:
Domain Error π©
the x argument is Β±Inf.
if the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [EDOM]. if the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid floating-point exception shall be raised.
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.
also jsyk: the following sections are informative. they're the bonus content, not the rules. π«Ά
π EXAMPLES π
π Taking the Sine of a 45-Degree Angle π
#include <math.h>
...
double radians = 45.0 * M_PI / 180;
double result;
...
result = sin(radians);
look at her go. converting degrees to radians and everything. main character energy. π
π§ APPLICATION USAGE π§
these functions may lose accuracy when their argument is near a multiple of Ο or is far from 0.0. so likeβ¦ be mindful, bestie, floating point is a hater sometimes. π
on error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other β but at least one of them must be non-zero. no skipping out of both, that's the law.
π RATIONALE π
None.
(yeah. nothing. she said what she said. π)
π FUTURE DIRECTIONS π
None.
(the future is⦠unchanged. lowkey refreshing.)
π₯ SEE ALSO π₯
asin()feclearexcept()fetestexcept()isnan()
the Base Definitions volume of POSIX.1β2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, <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 .
okay that's the whole page, you're all caught up π this one came to you from IEEE/The Open Group, 2017, filed under SIN(3POSIX) β go forth and compute some sines, bestie, you got this β¨π¦π
π¦ 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