1.\" $OpenBSD: fpclassify.3,v 1.3 2011/07/07 13:30:28 jmc Exp $ 2.\" 3.\" Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> 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.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.\" $FreeBSD: src/lib/libc/gen/fpclassify.3,v 1.6 2005/01/27 05:46:16 das Exp $ 28.\" 29.Dd $Mdocdate: July 7 2011 $ 30.Dt FPCLASSIFY 3 31.Os 32.Sh NAME 33.Nm fpclassify , 34.Nm isfinite , 35.Nm isinf , 36.Nm isnan , 37.Nm isnormal , 38.Nm signbit 39.Nd classify a floating-point number 40.Sh SYNOPSIS 41.In math.h 42.Ft int 43.Fn fpclassify "real-floating x" 44.Ft int 45.Fn isfinite "real-floating x" 46.Ft int 47.Fn isinf "real-floating x" 48.Ft int 49.Fn isnan "real-floating x" 50.Ft int 51.Fn isnormal "real-floating x" 52.Ft int 53.Fn signbit "real-floating x" 54.Sh DESCRIPTION 55The 56.Fn fpclassify 57macro takes an argument of 58.Fa x 59and returns one of the following manifest constants: 60.Pp 61.Bl -tag -width "FP_SUBNORMALXXX" -offset indent -compact 62.It Dv FP_INFINITE 63Indicates that 64.Fa x 65is an infinite number. 66.It Dv FP_NAN 67Indicates that 68.Fa x 69is not a number (NaN). 70.It Dv FP_NORMAL 71Indicates that 72.Fa x 73is a normalized number. 74.It Dv FP_SUBNORMAL 75Indicates that 76.Fa x 77is a denormalized number. 78.It Dv FP_ZERO 79Indicates that 80.Fa x 81is zero (0 or \-0). 82.El 83.Pp 84The 85.Fn isfinite 86macro returns a non-zero value if and only if its argument has 87a finite (zero, subnormal, or normal) value. 88.Pp 89The 90.Fn isinf , 91.Fn isnan , 92and 93.Fn isnormal 94macros return non-zero if and only if 95.Fa x 96is an infinity, NaN, 97or a non-zero normalized number, respectively. 98.Pp 99The 100.Fn signbit 101macro takes an argument of 102.Fa x 103and returns non-zero if the value of its sign is negative, otherwise 0. 104.Sh SEE ALSO 105.Xr isgreater 3 106.Sh STANDARDS 107The 108.Fn fpclassify , 109.Fn isfinite , 110.Fn isinf , 111.Fn isnan , 112.Fn isnormal , 113and 114.Fn signbit 115macros conform to 116.St -isoC-99 . 117.Pp 118The symbols 119.Fn isinff , 120and 121.Fn isnanf 122are provided as compatibility aliases to 123.Fn isinf , 124and 125.Fn isnan , 126respectively, and their uses are deprecated. 127Similarly, 128.Fn finite 129and 130.Fn finitef 131are deprecated versions of 132.Fn isfinite . 133.Sh HISTORY 134The 135.Fn fpclassify , 136.Fn isfinite , 137.Fn isinf , 138.Fn isnan , 139.Fn isnormal , 140and 141.Fn signbit 142macros were added in 143.Ox 4.4 . 144.Bx 3 145introduced 146.Fn isinf 147and 148.Fn isnan 149functions, which accepted 150.Vt double 151arguments; these have been superseded by the macros 152described above. 153.Sh BUGS 154.Tn VAX 155floating point does not have distinguished values 156for either infinity or not-a-number. 157.Fn isinf , 158.Fn isinff , 159.Fn isnan , 160and 161.Fn isnanf 162routines always return 0 on that architecture. 163Similarly, 164.Fn finite , 165and 166.Fn isfinite 167always return 1. 168