1fmod(3)                    Library Functions Manual                    fmod(3)
2
3
4

NAME

6       fmod, fmodf, fmodl - floating-point remainder function
7

LIBRARY

9       Math library (libm, -lm)
10

SYNOPSIS

12       #include <math.h>
13
14       double fmod(double x, double y);
15       float fmodf(float x, float y);
16       long double fmodl(long double x, long double y);
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       fmodf(), fmodl():
21           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
22               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
23               || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
24

DESCRIPTION

26       These  functions  compute the floating-point remainder of dividing x by
27       y.  The return value is x - n * y, where n is the quotient of  x  /  y,
28       rounded toward zero to an integer.
29

RETURN VALUE

31       On  success, these functions return the value x - n*y, for some integer
32       n, such that the returned value has the same sign as x and a  magnitude
33       less than the magnitude of y.
34
35       If x or y is a NaN, a NaN is returned.
36
37       If x is an infinity, a domain error occurs, and a NaN is returned.
38
39       If y is zero, a domain error occurs, and a NaN is returned.
40
41       If x is +0 (-0), and y is not zero, +0 (-0) is returned.
42

ERRORS

44       See  math_error(7) for information on how to determine whether an error
45       has occurred when calling these functions.
46
47       The following errors can occur:
48
49       Domain error: x is an infinity
50              errno is set to EDOM (but see BUGS).  An invalid  floating-point
51              exception (FE_INVALID) is raised.
52
53       Domain error: y is zero
54              errno  is  set  to  EDOM.   An  invalid floating-point exception
55              (FE_INVALID) is raised.
56

ATTRIBUTES

58       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
59       tributes(7).
60
61       ┌────────────────────────────────────────────┬───────────────┬─────────┐
62Interface                                   Attribute     Value   
63       ├────────────────────────────────────────────┼───────────────┼─────────┤
64fmod(), fmodf(), fmodl()                    │ Thread safety │ MT-Safe │
65       └────────────────────────────────────────────┴───────────────┴─────────┘
66

STANDARDS

68       C11, POSIX.1-2008.
69

HISTORY

71       C99, POSIX.1-2001.
72
73       The variant returning double also conforms to SVr4, 4.3BSD, C89.
74

BUGS

76       Before  glibc  2.10, the glibc implementation did not set errno to EDOM
77       when a domain error occurred for an infinite x.
78

SEE ALSO

80       remainder(3)
81
82
83
84Linux man-pages 6.05              2023-07-20                           fmod(3)
Impressum