xref: /freebsd/lib/msun/man/nan.3 (revision fcb560670601b2a4d87bb31d7531c8dcc37ee71b)
1.\" Copyright (c) 2007 David Schultz <das@FreeBSD.org>
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.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd December 16, 2007
28.Dt NAN 3
29.Os
30.Sh NAME
31.Nm nan ,
32.Nm nanf ,
33.Nm nanl
34.Nd quiet \*(Nas
35.Sh LIBRARY
36.Lb libm
37.Sh SYNOPSIS
38.In math.h
39.Ft double
40.Fn nan "const char *s"
41.Ft float
42.Fn nanf "const char *s"
43.Ft long double
44.Fn nanl "const char *s"
45.Sh DESCRIPTION
46The
47.Dv NAN
48macro expands to a quiet \*(Na (Not A Number).
49Similarly, each of the
50.Fn nan ,
51.Fn nanf ,
52and
53.Fn nanl
54functions generate a quiet \*(Na value without raising an invalid exception.
55The argument
56.Fa s
57should point to either an empty string or a hexadecimal representation
58of a non-negative integer (e.g., "0x1234".)
59In the latter case, the integer is encoded in some free bits in the
60representation of the \*(Na, which sometimes store
61machine-specific information about why a particular \*(Na was generated.
62There are 22 such bits available for
63.Vt float
64variables, 51 bits for
65.Vt double
66variables, and at least 51 bits for a
67.Vt long double .
68If
69.Fa s
70is improperly formatted or represents an integer that is too large,
71then the particular encoding of the quiet \*(Na that is returned
72is indeterminate.
73.Sh COMPATIBILITY
74Calling these functions with a non-empty string isn't portable.
75Another operating system may translate the string into a different
76\*(Na encoding, and furthermore, the meaning of a given \*(Na encoding
77varies across machine architectures.
78If you understood the innards of a particular platform well enough to
79know what string to use, then you would have no need for these functions
80anyway, so don't use them.
81Use the
82.Dv NAN
83macro instead.
84.Sh SEE ALSO
85.Xr fenv 3 ,
86.Xr ieee 3 ,
87.Xr isnan 3 ,
88.Xr math 3 ,
89.Xr strtod 3
90.Sh STANDARDS
91The
92.Fn nan ,
93.Fn nanf ,
94and
95.Fn nanl
96functions and the
97.Dv NAN
98macro conform to
99.St -isoC-99 .
100