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 June 20, 2004 36.Dt IEEE 3 37.Os 38.Sh NAME 39.Nm copysign , 40.Nm copysignf , 41.Nm copysignl , 42.Nm finite , 43.Nm finitef , 44.Nm ilogb , 45.Nm ilogbf , 46.Nm nextafter , 47.Nm nextafterf , 48.Nm remainder , 49.Nm remainderf , 50.Nm scalbln , 51.Nm scalblnf , 52.Nm scalbn , 53.Nm scalbnf 54.Nd functions for IEEE arithmetic 55.Sh LIBRARY 56.Lb libm 57.Sh SYNOPSIS 58.In math.h 59.Ft double 60.Fn copysign "double x" "double y" 61.Ft float 62.Fn copysignf "float x" "float y" 63.Ft long double 64.Fn copysignl "long double x" "long double y" 65.Ft int 66.Fn finite "double x" 67.Ft int 68.Fn finitef "float x" 69.Ft int 70.Fn ilogb "double x" 71.Ft int 72.Fn ilogbf "float x" 73.Ft double 74.Fn nextafter "double x" "double y" 75.Ft float 76.Fn nextafterf "float x" "float y" 77.Ft double 78.Fn remainder "double x" "double y" 79.Ft float 80.Fn remainderf "float x" "float y" 81.Ft double 82.Fn scalbln "double x" "long n" 83.Ft float 84.Fn scalblnf "float x" "long n" 85.Ft double 86.Fn scalbn "double x" "int n" 87.Ft float 88.Fn scalbnf "float x" "int n" 89.Sh DESCRIPTION 90These functions are required or recommended by 91.St -ieee754 . 92.Pp 93The 94.Fn copysign , 95.Fn copysignf 96and 97.Fn copysignl 98functions 99return 100.Fa x 101with its sign changed to 102.Fa y Ns 's . 103.Pp 104.Fn finite 105and 106.Fn finitef 107return the value 1 just when 108\-\*(If \*(Lt 109.Fa x 110\*(Lt +\*(If; 111otherwise a 112zero is returned 113(when 114.Pf \\*(Ba Ns Fa x Ns \\*(Ba 115= \*(If or 116.Fa x 117is \*(Na). 118.Pp 119.Fn ilogb 120and 121.Fn ilogbf 122return 123.Fa x Ns 's exponent, 124in integer format. 125.Fn ilogb \*(Pm\*(If 126returns 127.Dv INT_MAX , 128.Fn ilogb \*(Pm\*(Na 129returns 130.Dv FP_ILOGBNAN 131and 132.Fn ilogb 0 133returns 134.Dv FP_ILOGB0 . 135.Pp 136.Fn nextafter 137and 138.Fn nextafterf 139return the next machine representable number from 140.Fa x 141in direction 142.Fa y . 143.Pp 144.Fn remainder 145and 146.Fn remainderf 147return the remainder 148.Fa r 149:= 150.Fa x 151\- 152.Fa n\(**y 153where 154.Fa n 155is the integer nearest the exact value of 156.Bk -words 157.Fa x Ns / Ns Fa y ; 158.Ek 159moreover if 160.Pf \\*(Ba Fa n 161\- 162.Sm off 163.Fa x No / Fa y No \\*(Ba 164.Sm on 165= 1661/2 167then 168.Fa n 169is even. 170Consequently 171the remainder is computed exactly and 172.Sm off 173.Pf \\*(Ba Fa r No \\*(Ba 174.Sm on 175\*(Le 176.Sm off 177.Pf \\*(Ba Fa y No \\*(Ba/2 . 178.Sm on 179But 180.Fn remainder x 0 181and 182.Fn remainder \*(If 0 183are invalid operations that produce a \*(Na. 184.Pp 185.Fn scalbln , 186.Fn scalblnf , 187.Fn scalbn , 188and 189.Fn scalbnf 190return 191.Fa x Ns \(**(2** Ns Fa n ) 192computed by exponent manipulation. 193.Sh SEE ALSO 194.Xr math 3 195.Sh HISTORY 196The 197.Nm ieee 198functions appeared in 199.Bx 4.3 . 200The 201.Fn copysignl , 202.Fn scalbln , 203and 204.Fn scalblnf 205functions first appeared in 206.Fx 5.3 . 207.Sh STANDARDS 208.St -ieee754 209