The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 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: src/lib/msun/man/remainder.3,v 1.4 2005/11/24 09:25:10 joel Exp $ |
| 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 , |
| 60 | and |
| 61 | .Fn remquof |
| 62 | return the remainder |
| 63 | .Fa r |
| 64 | := |
| 65 | .Fa x |
| 66 | \- |
| 67 | .Fa n\(**y |
| 68 | where |
| 69 | .Fa n |
| 70 | is the integer nearest the exact value of |
| 71 | .Bk -words |
| 72 | .Fa x Ns / Ns Fa y ; |
| 73 | .Ek |
| 74 | moreover if |
| 75 | .Pf \\*(Ba Fa n |
| 76 | \- |
| 77 | .Sm off |
| 78 | .Fa x No / Fa y No \\*(Ba |
| 79 | .Sm on |
| 80 | = |
| 81 | 1/2 |
| 82 | then |
| 83 | .Fa n |
| 84 | is even. |
| 85 | Consequently |
| 86 | the 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 |
| 94 | But attempting to take the remainder when |
| 95 | .Fa y |
| 96 | is 0 or |
| 97 | .Fa x |
| 98 | is \*(Pm\*(If is an invalid operation that produces a \*(Na. |
| 99 | .Pp |
| 100 | The |
| 101 | .Fn remquo |
| 102 | and |
| 103 | .Fn remquof |
| 104 | functions also store the last |
| 105 | .Va k |
| 106 | bits of |
| 107 | .Fa n |
| 108 | in the location pointed to by |
| 109 | .Fa quo , |
| 110 | provided that |
| 111 | .Fa n |
| 112 | exists. |
| 113 | The number of bits |
| 114 | .Va k |
| 115 | is 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 |
| 121 | The |
| 122 | .Fn remainder , |
| 123 | .Fn remainderf , |
| 124 | .Fn remquo , |
| 125 | and |
| 126 | .Fn remquof |
| 127 | routines conform to |
| 128 | .St -isoC-99 . |
| 129 | The remainder is as defined in |
| 130 | .St -ieee754 . |
| 131 | .Sh HISTORY |
| 132 | The |
| 133 | .Fn remainder |
| 134 | and |
| 135 | .Fn remainderf |
| 136 | functions appeared in |
| 137 | .Bx 4.3 |
| 138 | and |
| 139 | .Fx 2.0 , |
| 140 | respectively. |
| 141 | The |
| 142 | .Fn remquo |
| 143 | and |
| 144 | .Fn remquof |
| 145 | functions were added in |
| 146 | .Fx 6.0 . |