]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
1cc72c09 MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
fea681da | 4 | .\" |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
6 | .\" Permission is granted to make and distribute verbatim copies of this |
7 | .\" manual provided the copyright notice and this permission notice are | |
8 | .\" preserved on all copies. | |
9 | .\" | |
10 | .\" Permission is granted to copy and distribute modified versions of this | |
11 | .\" manual under the conditions for verbatim copying, provided that the | |
12 | .\" entire resulting derived work is distributed under the terms of a | |
13 | .\" permission notice identical to this one. | |
c13182ef | 14 | .\" |
fea681da MK |
15 | .\" Since the Linux kernel and libraries are constantly changing, this |
16 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
17 | .\" responsibility for errors or omissions, or for damages resulting from | |
18 | .\" the use of the information contained herein. The author(s) may not | |
19 | .\" have taken the same level of care in the production of this manual, | |
20 | .\" which is licensed free of charge, as they might when working | |
21 | .\" professionally. | |
c13182ef | 22 | .\" |
fea681da MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
fea681da MK |
26 | .\" |
27 | .\" References consulted: | |
28 | .\" Linux libc source code | |
29 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
30 | .\" 386BSD man pages | |
31 | .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) | |
32 | .\" Modified 2002-07-27 by Walter Harms | |
33 | .\" (walter.harms@informatik.uni-oldenburg.de) | |
34 | .\" | |
fe0fefbf | 35 | .TH FMOD 3 2015-03-02 "" "Linux Programmer's Manual" |
fea681da MK |
36 | .SH NAME |
37 | fmod, fmodf, fmodl \- floating-point remainder function | |
38 | .SH SYNOPSIS | |
39 | .nf | |
40 | .B #include <math.h> | |
41 | .sp | |
42 | .BI "double fmod(double " x ", double " y ); | |
d39541ec | 43 | .br |
fea681da | 44 | .BI "float fmodf(float " x ", float " y ); |
d39541ec | 45 | .br |
fea681da MK |
46 | .BI "long double fmodl(long double " x ", long double " y ); |
47 | .fi | |
48 | .sp | |
20c58d70 | 49 | Link with \fI\-lm\fP. |
1cc72c09 MK |
50 | .sp |
51 | .in -4n | |
52 | Feature Test Macro Requirements for glibc (see | |
53 | .BR feature_test_macros (7)): | |
54 | .in | |
55 | .sp | |
56 | .ad l | |
57 | .BR fmodf (), | |
58 | .BR fmodl (): | |
b90c43a8 | 59 | .RS 4 |
8b0d34e4 MK |
60 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || |
61 | _POSIX_C_SOURCE\ >=\ 200112L; | |
b90c43a8 MK |
62 | .br |
63 | or | |
1cc72c09 | 64 | .I cc\ -std=c99 |
b90c43a8 MK |
65 | .RE |
66 | .ad | |
fea681da | 67 | .SH DESCRIPTION |
5600f73a | 68 | These functions compute the floating-point remainder of dividing |
022671eb MK |
69 | .I x |
70 | by | |
71 | .IR y . | |
72 | The return value is | |
51700fd7 | 73 | .IR x |
022671eb MK |
74 | \- |
75 | .I n | |
76 | * | |
77 | .IR y , | |
78 | where | |
79 | .I n | |
80 | is the quotient of | |
81 | .I x | |
82 | / | |
83 | .IR y , | |
84 | rounded toward zero to an integer. | |
47297adb | 85 | .SH RETURN VALUE |
1cc72c09 MK |
86 | On success, these |
87 | functions return the value \fIx\fP\ \-\ \fIn\fP*\fIy\fP, | |
022671eb MK |
88 | for some integer |
89 | .IR n , | |
1cc72c09 MK |
90 | such that the returned value has the same sign as |
91 | .I x | |
92 | and a magnitude less than the magnitude of | |
93 | .IR y . | |
94 | ||
95 | If | |
96 | .I x | |
97 | or | |
98 | .I y | |
99 | is a NaN, a NaN is returned. | |
100 | ||
101 | If | |
102 | .I x | |
385cf745 | 103 | is an infinity, |
efe294cb | 104 | a domain error occurs, and |
1cc72c09 MK |
105 | a NaN is returned. |
106 | ||
107 | If | |
108 | .I y | |
109 | is zero, | |
efe294cb | 110 | a domain error occurs, and |
1cc72c09 MK |
111 | a NaN is returned. |
112 | ||
113 | If | |
114 | .I x | |
115 | is +0 (\-0), and | |
116 | .I y | |
117 | is not zero, +0 (\-0) is returned. | |
fea681da | 118 | .SH ERRORS |
1cc72c09 MK |
119 | See |
120 | .BR math_error (7) | |
121 | for information on how to determine whether an error has occurred | |
122 | when calling these functions. | |
123 | .PP | |
124 | The following errors can occur: | |
125 | .TP | |
126 | Domain error: \fIx\fP is an infinity | |
9343357b MK |
127 | .I errno |
128 | is set to | |
129 | .BR EDOM | |
130 | (but see BUGS). | |
1cc72c09 MK |
131 | An invalid floating-point exception |
132 | .RB ( FE_INVALID ) | |
133 | is raised. | |
fea681da | 134 | .TP |
1cc72c09 MK |
135 | Domain error: \fIy\fP is zero |
136 | .I errno | |
137 | is set to | |
138 | .BR EDOM . | |
139 | An invalid floating-point exception | |
140 | .RB ( FE_INVALID ) | |
141 | is raised. | |
142 | .\" POSIX.1 documents an optional underflow error, but AFAICT it doesn't | |
143 | .\" (can't?) occur -- mtk, Jul 2008 | |
86576222 MS |
144 | .SH ATTRIBUTES |
145 | For an explanation of the terms used in this section, see | |
146 | .BR attributes (7). | |
147 | .TS | |
148 | allbox; | |
149 | lbw24 lb lb | |
150 | l l l. | |
151 | Interface Attribute Value | |
152 | T{ | |
153 | .BR fmod (), | |
154 | .BR fmodf (), | |
155 | .BR fmodl () | |
156 | T} Thread safety MT-Safe | |
157 | .TE | |
47297adb | 158 | .SH CONFORMING TO |
9a74e018 | 159 | C99, POSIX.1-2001, POSIX.1-2008. |
e05e3635 | 160 | |
22cb459d MK |
161 | The variant returning |
162 | .I double | |
163 | also conforms to | |
164 | SVr4, 4.3BSD, C89. | |
9343357b MK |
165 | .SH BUGS |
166 | Before version 2.10, the glibc implementation did not set | |
167 | .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6784 | |
168 | .I errno | |
169 | to | |
170 | .B EDOM | |
171 | when a domain error occurred for an infinite | |
172 | .IR x . | |
47297adb | 173 | .SH SEE ALSO |
fea681da | 174 | .BR remainder (3) |