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.\" 4. 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.\" $FreeBSD$ 30.\" 31.Dd March 24, 2005 32.Dt REMAINDER 3 33.Os 34.Sh NAME 35.Nm remainder , 36.Nm remainderf , 37.Nm remquo , 38.Nm remquof 39.Nd minimal residue functions 40.Sh LIBRARY 41.Lb libm 42.Sh SYNOPSIS 43.In math.h 44.Ft double 45.Fn remainder "double x" "double y" 46.Ft float 47.Fn remainderf "float x" "float y" 48.Ft double 49.Fn remquo "double x" "double y" "int *quo" 50.Ft float 51.Fn remquof "float x" "float y" "int *quo" 52.Sh DESCRIPTION 53.Fn remainder , 54.Fn remainderf , 55.Fn remquo , 56and 57.Fn remquof 58return the remainder 59.Fa r 60:= 61.Fa x 62\- 63.Fa n\(**y 64where 65.Fa n 66is the integer nearest the exact value of 67.Bk -words 68.Fa x Ns / Ns Fa y ; 69.Ek 70moreover if 71.Pf \\*(Ba Fa n 72\- 73.Sm off 74.Fa x No / Fa y No \\*(Ba 75.Sm on 76= 771/2 78then 79.Fa n 80is even. 81Consequently 82the remainder is computed exactly and 83.Sm off 84.Pf \\*(Ba Fa r No \\*(Ba 85.Sm on 86\*(Le 87.Sm off 88.Pf \\*(Ba Fa y No \\*(Ba/2 . 89.Sm on 90But attempting to take the remainder when 91.Fa y 92is 0 or 93.Fa x 94is \*(Pm\*(If is an invalid operation that produces a \*(Na. 95.Pp 96The 97.Fn remquo 98and 99.Fn remquof 100functions also store the last 101.Va k 102bits of 103.Fa n 104in the location pointed to by 105.Fa quo , 106provided that 107.Fa n 108exists. 109The number of bits 110.Va k 111is platform-specific, but is guaranteed to be at least 3. 112.Sh SEE ALSO 113.Xr fmod 3 , 114.Xr ieee 3 , 115.Xr math 3 116.Sh STANDARDS 117The 118.Fn remainder , 119.Fn remainderf , 120.Fn remquo , 121and 122.Fn remquof 123routines conform to 124.St -isoC-99 . 125The remainder is as defined in 126.St -ieee754 . 127.Sh HISTORY 128The 129.Fn remainder 130and 131.Fn remainderf 132functions appeared in 133.Bx 4.3 134and 135.Fx 2.0 , 136respectively. 137The 138.Fn remquo 139and 140.Fn remquof 141functions were added in 142.Fx 6.0 . 143