1.\" $OpenBSD: remainder.3,v 1.4 2010/03/26 19:30:40 jmc Exp $ 2.\" 3.\" Copyright (c) 1985, 1991 Regents of the University of California. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 4. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91 31.\" $FreeBSD: src/lib/msun/man/remainder.3,v 1.6 2008/03/30 20:48:02 das Exp $ 32.\" 33.Dd $Mdocdate: March 26 2010 $ 34.Dt REMAINDER 3 35.Os 36.Sh NAME 37.Nm remainder , 38.Nm remainderf , 39.Nm remquo , 40.Nm remquof 41.Nd minimal residue functions 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 math 3 , 115.Xr nextafter 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.Pp 128.Fn drem 129and 130.Fn dremf 131are deprecated aliases for 132.Fn remainder 133and 134.Fn remainderf , 135respectively. 136.Sh HISTORY 137The 138.Fn remainder 139and 140.Fn remainderf 141functions appeared in 142.Bx 4.3 143and 144.Nx 1.2 , 145respectively. 146The 147.Fn remquo 148and 149.Fn remquof 150functions were added in 151.Ox 4.4 . 152