1SIN(3P) POSIX Programmer's Manual SIN(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 sin, sinf, sinl - sine function
13
15 #include <math.h>
16
17 double sin(double x);
18 float sinf(float x);
19 long double sinl(long double x);
20
21
23 These functions shall compute the sine of their argument x, measured in
24 radians.
25
26 An application wishing to check for error situations should set errno
27 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
28 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
29 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
30 occurred.
31
33 Upon successful completion, these functions shall return the sine of x.
34
35 If x is NaN, a NaN shall be returned.
36
37 If x is ±0, x shall be returned.
38
39 If x is subnormal, a range error may occur and x should be returned.
40
41 If x is ±Inf, a domain error shall occur, and either a NaN (if sup‐
42 ported), or an implementation-defined value shall be returned.
43
45 These functions shall fail if:
46
47 Domain Error
48 The x argument is ±Inf.
49
50 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
51 then errno shall be set to [EDOM]. If the integer expression
52 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid
53 floating-point exception shall be raised.
54
55
56 These functions may fail if:
57
58 Range Error
59 The value of x is subnormal
60
61 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
62 then errno shall be set to [ERANGE]. If the integer expression
63 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
64 floating-point exception shall be raised.
65
66
67 The following sections are informative.
68
70 Taking the Sine of a 45-Degree Angle
71 #include <math.h>
72 ...
73 double radians = 45.0 * M_PI / 180;
74 double result;
75 ...
76 result = sin(radians);
77
79 These functions may lose accuracy when their argument is near a multi‐
80 ple of pi or is far from 0.0.
81
82 On error, the expressions (math_errhandling & MATH_ERRNO) and
83 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
84 at least one of them must be non-zero.
85
87 None.
88
90 None.
91
93 asin(), feclearexcept(), fetestexcept(), isnan(), the Base Definitions
94 volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error Condi‐
95 tions for Mathematical Functions, <math.h>
96
98 Portions of this text are reprinted and reproduced in electronic form
99 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
100 -- Portable Operating System Interface (POSIX), The Open Group Base
101 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
102 Electrical and Electronics Engineers, Inc and The Open Group. In the
103 event of any discrepancy between this version and the original IEEE and
104 The Open Group Standard, the original IEEE and The Open Group Standard
105 is the referee document. The original Standard can be obtained online
106 at http://www.opengroup.org/unix/online.html .
107
108
109
110IEEE/The Open Group 2003 SIN(3P)