1.\" $OpenBSD: fpclassify.3,v 1.2 2008/07/29 20:11:45 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 29 2008 $ 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.Xr math 3 107.Sh STANDARDS 108The 109.Fn fpclassify , 110.Fn isfinite , 111.Fn isinf , 112.Fn isnan , 113.Fn isnormal , 114and 115.Fn signbit 116macros conform to 117.St -isoC-99 . 118.Pp 119The symbols 120.Fn isinff , 121and 122.Fn isnanf 123are provided as compatibility aliases to 124.Fn isinf , 125and 126.Fn isnan , 127respectively, and their uses are deprecated. 128Similarly, 129.Fn finite 130and 131.Fn finitef 132are deprecated versions of 133.Fn isfinite . 134.Sh HISTORY 135The 136.Fn fpclassify , 137.Fn isfinite , 138.Fn isinf , 139.Fn isnan , 140.Fn isnormal , 141and 142.Fn signbit 143macros were added in 144.Ox 4.4 . 145.Bx 3 146introduced 147.Fn isinf 148and 149.Fn isnan 150functions, which accepted 151.Vt double 152arguments; these have been superseded by the macros 153described above. 154.Sh BUGS 155.Tn VAX 156floating point does not have distinguished values 157for either infinity or not-a-number. 158.Fn isinf , 159.Fn isinff , 160.Fn isnan , 161and 162.Fn isnanf 163routines always return 0 on that architecture. 164Similarly, 165.Fn finite , 166and 167.Fn isfinite 168always return 1. 169