Changes: Ready for 5.13
[man-pages.git] / man3 / sincos.3
blob4834da815ac4f92f35d8920137e0529d6c6eac23
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
6 .\" Distributed under GPL
7 .\" %%%LICENSE_END
8 .\"
9 .TH SINCOS 3  2021-03-22 "GNU" "Linux Programmer's Manual"
10 .SH NAME
11 sincos, sincosf, sincosl \- calculate sin and cos simultaneously
12 .SH SYNOPSIS
13 .nf
14 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
15 .B #include <math.h>
16 .PP
17 .BI "void sincos(double " x ", double *" sin ", double *" cos );
18 .BI "void sincosf(float " x ", float *" sin ", float *" cos );
19 .BI "void sincosl(long double " x ", long double *" sin ", long double *" cos );
20 .fi
21 .PP
22 Link with \fI\-lm\fP.
23 .SH DESCRIPTION
24 Several applications need sine and cosine of the same angle
25 .IR x .
26 These functions compute both at the same time, and store the results in
27 .I *sin
28 and
29 .IR *cos .
30 Using this function can be more efficient than two separate calls to
31 .BR sin (3)
32 and
33 .BR cos (3).
34 .PP
36 .I x
37 is a NaN,
38 a NaN is returned in
39 .I *sin
40 and
41 .IR *cos .
42 .PP
44 .I x
45 is positive infinity or negative infinity,
46 a domain error occurs, and
47 a NaN is returned in
48 .I *sin
49 and
50 .IR *cos .
51 .SH RETURN VALUE
52 These functions return
53 .IR void .
54 .SH ERRORS
55 See
56 .BR math_error (7)
57 for information on how to determine whether an error has occurred
58 when calling these functions.
59 .PP
60 The following errors can occur:
61 .TP
62 Domain error: \fIx\fP is an infinity
63 .I errno
64 is set to
65 .BR EDOM
66 (but see BUGS).
67 An invalid floating-point exception
68 .RB ( FE_INVALID )
69 is raised.
70 .SH VERSIONS
71 These functions first appeared in glibc in version 2.1.
72 .SH ATTRIBUTES
73 For an explanation of the terms used in this section, see
74 .BR attributes (7).
75 .ad l
76 .nh
77 .TS
78 allbox;
79 lbx lb lb
80 l l l.
81 Interface       Attribute       Value
83 .BR sincos (),
84 .BR sincosf (),
85 .BR sincosl ()
86 T}      Thread safety   MT-Safe
87 .TE
88 .hy
89 .ad
90 .sp 1
91 .SH CONFORMING TO
92 These functions are GNU extensions.
93 .SH NOTES
94 To see the performance advantage of
95 .BR sincos (),
96 it may be necessary to disable
97 .BR gcc (1)
98 built-in optimizations, using flags such as:
99 .PP
100 .in +4n
102 cc \-O \-lm \-fno\-builtin prog.c
105 .SH BUGS
106 Before version 2.22, the glibc implementation did not set
107 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=15467
108 .I errno
110 .B EDOM
111 when a domain error occurred.
112 .SH SEE ALSO
113 .BR cos (3),
114 .BR sin (3),
115 .BR tan (3)