]>
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 | .\" |
5fbde956 | 5 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
6 | .\" |
7 | .\" References consulted: | |
8 | .\" Linux libc source code | |
9 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
10 | .\" 386BSD man pages | |
11 | .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) | |
12 | .\" Modified 2002-07-27 by Walter Harms | |
13 | .\" (walter.harms@informatik.uni-oldenburg.de) | |
14 | .\" | |
4c1c5274 | 15 | .TH fmod 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
16 | .SH NAME |
17 | fmod, fmodf, fmodl \- floating-point remainder function | |
2af19291 AC |
18 | .SH LIBRARY |
19 | Math library | |
8fc3b2cf | 20 | .RI ( libm ", " \-lm ) |
fea681da MK |
21 | .SH SYNOPSIS |
22 | .nf | |
23 | .B #include <math.h> | |
68e4db0a | 24 | .PP |
fea681da | 25 | .BI "double fmod(double " x ", double " y ); |
fea681da | 26 | .BI "float fmodf(float " x ", float " y ); |
fea681da MK |
27 | .BI "long double fmodl(long double " x ", long double " y ); |
28 | .fi | |
68e4db0a | 29 | .PP |
d39ad78f | 30 | .RS -4 |
1cc72c09 MK |
31 | Feature Test Macro Requirements for glibc (see |
32 | .BR feature_test_macros (7)): | |
d39ad78f | 33 | .RE |
68e4db0a | 34 | .PP |
1cc72c09 MK |
35 | .BR fmodf (), |
36 | .BR fmodl (): | |
9d2adbae | 37 | .nf |
5c10d2c5 | 38 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae MK |
39 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
40 | || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
41 | .fi | |
fea681da | 42 | .SH DESCRIPTION |
5600f73a | 43 | These functions compute the floating-point remainder of dividing |
022671eb MK |
44 | .I x |
45 | by | |
46 | .IR y . | |
47 | The return value is | |
1ae6b2c7 | 48 | .I x |
022671eb MK |
49 | \- |
50 | .I n | |
51 | * | |
52 | .IR y , | |
53 | where | |
54 | .I n | |
55 | is the quotient of | |
56 | .I x | |
57 | / | |
58 | .IR y , | |
59 | rounded toward zero to an integer. | |
47297adb | 60 | .SH RETURN VALUE |
1cc72c09 MK |
61 | On success, these |
62 | functions return the value \fIx\fP\ \-\ \fIn\fP*\fIy\fP, | |
022671eb MK |
63 | for some integer |
64 | .IR n , | |
1cc72c09 MK |
65 | such that the returned value has the same sign as |
66 | .I x | |
67 | and a magnitude less than the magnitude of | |
68 | .IR y . | |
847e0d88 | 69 | .PP |
1cc72c09 MK |
70 | If |
71 | .I x | |
72 | or | |
73 | .I y | |
74 | is a NaN, a NaN is returned. | |
847e0d88 | 75 | .PP |
1cc72c09 MK |
76 | If |
77 | .I x | |
385cf745 | 78 | is an infinity, |
efe294cb | 79 | a domain error occurs, and |
1cc72c09 | 80 | a NaN is returned. |
847e0d88 | 81 | .PP |
1cc72c09 MK |
82 | If |
83 | .I y | |
84 | is zero, | |
efe294cb | 85 | a domain error occurs, and |
1cc72c09 | 86 | a NaN is returned. |
847e0d88 | 87 | .PP |
1cc72c09 MK |
88 | If |
89 | .I x | |
90 | is +0 (\-0), and | |
91 | .I y | |
92 | is not zero, +0 (\-0) is returned. | |
fea681da | 93 | .SH ERRORS |
1cc72c09 MK |
94 | See |
95 | .BR math_error (7) | |
96 | for information on how to determine whether an error has occurred | |
97 | when calling these functions. | |
98 | .PP | |
99 | The following errors can occur: | |
100 | .TP | |
101 | Domain error: \fIx\fP is an infinity | |
9343357b MK |
102 | .I errno |
103 | is set to | |
1ae6b2c7 | 104 | .B EDOM |
9343357b | 105 | (but see BUGS). |
1cc72c09 MK |
106 | An invalid floating-point exception |
107 | .RB ( FE_INVALID ) | |
108 | is raised. | |
fea681da | 109 | .TP |
1cc72c09 MK |
110 | Domain error: \fIy\fP is zero |
111 | .I errno | |
112 | is set to | |
113 | .BR EDOM . | |
114 | An invalid floating-point exception | |
115 | .RB ( FE_INVALID ) | |
116 | is raised. | |
117 | .\" POSIX.1 documents an optional underflow error, but AFAICT it doesn't | |
118 | .\" (can't?) occur -- mtk, Jul 2008 | |
86576222 MS |
119 | .SH ATTRIBUTES |
120 | For an explanation of the terms used in this section, see | |
121 | .BR attributes (7). | |
c466875e MK |
122 | .ad l |
123 | .nh | |
86576222 MS |
124 | .TS |
125 | allbox; | |
c466875e | 126 | lbx lb lb |
86576222 MS |
127 | l l l. |
128 | Interface Attribute Value | |
129 | T{ | |
130 | .BR fmod (), | |
131 | .BR fmodf (), | |
132 | .BR fmodl () | |
133 | T} Thread safety MT-Safe | |
134 | .TE | |
c466875e MK |
135 | .hy |
136 | .ad | |
137 | .sp 1 | |
3113c7f3 | 138 | .SH STANDARDS |
9a74e018 | 139 | C99, POSIX.1-2001, POSIX.1-2008. |
847e0d88 | 140 | .PP |
22cb459d MK |
141 | The variant returning |
142 | .I double | |
143 | also conforms to | |
144 | SVr4, 4.3BSD, C89. | |
9343357b MK |
145 | .SH BUGS |
146 | Before version 2.10, the glibc implementation did not set | |
147 | .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6784 | |
148 | .I errno | |
149 | to | |
150 | .B EDOM | |
151 | when a domain error occurred for an infinite | |
152 | .IR x . | |
47297adb | 153 | .SH SEE ALSO |
fea681da | 154 | .BR remainder (3) |