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