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