]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/fmod.3
990a0f5562ce8f194ae2710a764870eeb738223e
[thirdparty/man-pages.git] / man3 / fmod.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
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 .\"
15 .TH FMOD 3 2021-03-22 "" "Linux Programmer's Manual"
16 .SH NAME
17 fmod, fmodf, fmodl \- floating-point remainder function
18 .SH LIBRARY
19 Math library
20 .RI ( libm ", " \-lm )
21 .SH SYNOPSIS
22 .nf
23 .B #include <math.h>
24 .PP
25 .BI "double fmod(double " x ", double " y );
26 .BI "float fmodf(float " x ", float " y );
27 .BI "long double fmodl(long double " x ", long double " y );
28 .fi
29 .PP
30 .RS -4
31 Feature Test Macro Requirements for glibc (see
32 .BR feature_test_macros (7)):
33 .RE
34 .PP
35 .BR fmodf (),
36 .BR fmodl ():
37 .nf
38 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
39 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
40 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
41 .fi
42 .SH DESCRIPTION
43 These functions compute the floating-point remainder of dividing
44 .I x
45 by
46 .IR y .
47 The return value is
48 .IR x
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.
60 .SH RETURN VALUE
61 On success, these
62 functions return the value \fIx\fP\ \-\ \fIn\fP*\fIy\fP,
63 for some integer
64 .IR n ,
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 .
69 .PP
70 If
71 .I x
72 or
73 .I y
74 is a NaN, a NaN is returned.
75 .PP
76 If
77 .I x
78 is an infinity,
79 a domain error occurs, and
80 a NaN is returned.
81 .PP
82 If
83 .I y
84 is zero,
85 a domain error occurs, and
86 a NaN is returned.
87 .PP
88 If
89 .I x
90 is +0 (\-0), and
91 .I y
92 is not zero, +0 (\-0) is returned.
93 .SH ERRORS
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
102 .I errno
103 is set to
104 .BR EDOM
105 (but see BUGS).
106 An invalid floating-point exception
107 .RB ( FE_INVALID )
108 is raised.
109 .TP
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
119 .SH ATTRIBUTES
120 For an explanation of the terms used in this section, see
121 .BR attributes (7).
122 .ad l
123 .nh
124 .TS
125 allbox;
126 lbx lb lb
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
135 .hy
136 .ad
137 .sp 1
138 .SH CONFORMING TO
139 C99, POSIX.1-2001, POSIX.1-2008.
140 .PP
141 The variant returning
142 .I double
143 also conforms to
144 SVr4, 4.3BSD, C89.
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 .
153 .SH SEE ALSO
154 .BR remainder (3)