xref: /freebsd/lib/msun/man/remainder.3 (revision 19797b22561b52658349347f05dc92f69ae08947)
1.\" Copyright (c) 1985, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
33.\" $FreeBSD$
34.\"
35.Dd March 24, 2005
36.Dt REMAINDER 3
37.Os
38.Sh NAME
39.Nm remainder ,
40.Nm remainderf ,
41.Nm remquo ,
42.Nm remquof
43.Nd minimal residue functions
44.Sh LIBRARY
45.Lb libm
46.Sh SYNOPSIS
47.In math.h
48.Ft double
49.Fn remainder "double x" "double y"
50.Ft float
51.Fn remainderf "float x" "float y"
52.Ft double
53.Fn remquo "double x" "double y" "int *quo"
54.Ft float
55.Fn remquof "float x" "float y" "int *quo"
56.Sh DESCRIPTION
57.Fn remainder ,
58.Fn remainderf ,
59.Fn remquo ,
60and
61.Fn remquof
62return the remainder
63.Fa r
64:=
65.Fa x
66\-
67.Fa n\(**y
68where
69.Fa n
70is the integer nearest the exact value of
71.Bk -words
72.Fa x Ns / Ns Fa y ;
73.Ek
74moreover if
75.Pf \\*(Ba Fa n
76\-
77.Sm off
78.Fa x No / Fa y No \\*(Ba
79.Sm on
80=
811/2
82then
83.Fa n
84is even.
85Consequently
86the remainder is computed exactly and
87.Sm off
88.Pf \\*(Ba Fa r No \\*(Ba
89.Sm on
90\*(Le
91.Sm off
92.Pf \\*(Ba Fa y No \\*(Ba/2 .
93.Sm on
94But attempting to take the remainder when
95.Fa y
96is 0 or
97.Fa x
98is \*(Pm\*(If is an invalid operation that produces a \*(Na.
99.Pp
100The
101.Fn remquo
102and
103.Fn remquof
104functions also store the last
105.Va k
106bits of
107.Fa n
108in the location pointed to by
109.Fa quo ,
110provided that
111.Fa n
112exists.
113The number of bits
114.Va k
115is platform-specific, but is guaranteed to be at least 3.
116.Sh SEE ALSO
117.Xr fmod 3 ,
118.Xr ieee 3 ,
119.Xr math 3
120.Sh STANDARDS
121The
122.Fn remainder ,
123.Fn remainderf ,
124.Fn remquo ,
125and
126.Fn remquof
127routines conform to
128.St -isoC-99 .
129The remainder is as defined in
130.St -ieee754 .
131.Sh HISTORY
132The
133.Fn remainder
134and
135.Fn remainderf
136functions appeared in
137.Bx 4.3
138and
139.Fx 2.0 ,
140respectively.
141The
142.Fn remquo
143and
144.Fn remquof
145functions were added in
146.Fx 6.0 .
147