xref: /freebsd/lib/msun/man/nan.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
14b6b5744SDavid Schultz.\" Copyright (c) 2007 David Schultz <das@FreeBSD.org>
24b6b5744SDavid Schultz.\" All rights reserved.
34b6b5744SDavid Schultz.\"
44b6b5744SDavid Schultz.\" Redistribution and use in source and binary forms, with or without
54b6b5744SDavid Schultz.\" modification, are permitted provided that the following conditions
64b6b5744SDavid Schultz.\" are met:
74b6b5744SDavid Schultz.\" 1. Redistributions of source code must retain the above copyright
84b6b5744SDavid Schultz.\"    notice, this list of conditions and the following disclaimer.
94b6b5744SDavid Schultz.\" 2. Redistributions in binary form must reproduce the above copyright
104b6b5744SDavid Schultz.\"    notice, this list of conditions and the following disclaimer in the
114b6b5744SDavid Schultz.\"    documentation and/or other materials provided with the distribution.
124b6b5744SDavid Schultz.\"
134b6b5744SDavid Schultz.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
144b6b5744SDavid Schultz.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
154b6b5744SDavid Schultz.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
164b6b5744SDavid Schultz.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
174b6b5744SDavid Schultz.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184b6b5744SDavid Schultz.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
194b6b5744SDavid Schultz.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
204b6b5744SDavid Schultz.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
214b6b5744SDavid Schultz.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
224b6b5744SDavid Schultz.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
234b6b5744SDavid Schultz.\" SUCH DAMAGE.
244b6b5744SDavid Schultz.\"
254b6b5744SDavid Schultz.Dd December 16, 2007
264b6b5744SDavid Schultz.Dt NAN 3
274b6b5744SDavid Schultz.Os
284b6b5744SDavid Schultz.Sh NAME
294b6b5744SDavid Schultz.Nm nan ,
304b6b5744SDavid Schultz.Nm nanf ,
314b6b5744SDavid Schultz.Nm nanl
324b6b5744SDavid Schultz.Nd quiet \*(Nas
334b6b5744SDavid Schultz.Sh LIBRARY
344b6b5744SDavid Schultz.Lb libm
354b6b5744SDavid Schultz.Sh SYNOPSIS
364b6b5744SDavid Schultz.In math.h
374b6b5744SDavid Schultz.Ft double
384b6b5744SDavid Schultz.Fn nan "const char *s"
394b6b5744SDavid Schultz.Ft float
404b6b5744SDavid Schultz.Fn nanf "const char *s"
414b6b5744SDavid Schultz.Ft long double
424b6b5744SDavid Schultz.Fn nanl "const char *s"
434b6b5744SDavid Schultz.Sh DESCRIPTION
444b6b5744SDavid SchultzThe
454b6b5744SDavid Schultz.Dv NAN
464b6b5744SDavid Schultzmacro expands to a quiet \*(Na (Not A Number).
474b6b5744SDavid SchultzSimilarly, each of the
484b6b5744SDavid Schultz.Fn nan ,
494b6b5744SDavid Schultz.Fn nanf ,
504b6b5744SDavid Schultzand
514b6b5744SDavid Schultz.Fn nanl
524b6b5744SDavid Schultzfunctions generate a quiet \*(Na value without raising an invalid exception.
534b6b5744SDavid SchultzThe argument
544b6b5744SDavid Schultz.Fa s
554b6b5744SDavid Schultzshould point to either an empty string or a hexadecimal representation
564b6b5744SDavid Schultzof a non-negative integer (e.g., "0x1234".)
574b6b5744SDavid SchultzIn the latter case, the integer is encoded in some free bits in the
584b6b5744SDavid Schultzrepresentation of the \*(Na, which sometimes store
594b6b5744SDavid Schultzmachine-specific information about why a particular \*(Na was generated.
604b6b5744SDavid SchultzThere are 22 such bits available for
614b6b5744SDavid Schultz.Vt float
624b6b5744SDavid Schultzvariables, 51 bits for
634b6b5744SDavid Schultz.Vt double
644b6b5744SDavid Schultzvariables, and at least 51 bits for a
654b6b5744SDavid Schultz.Vt long double .
664b6b5744SDavid SchultzIf
674b6b5744SDavid Schultz.Fa s
684b6b5744SDavid Schultzis improperly formatted or represents an integer that is too large,
694b6b5744SDavid Schultzthen the particular encoding of the quiet \*(Na that is returned
704b6b5744SDavid Schultzis indeterminate.
714b6b5744SDavid Schultz.Sh COMPATIBILITY
724b6b5744SDavid SchultzCalling these functions with a non-empty string isn't portable.
734b6b5744SDavid SchultzAnother operating system may translate the string into a different
744b6b5744SDavid Schultz\*(Na encoding, and furthermore, the meaning of a given \*(Na encoding
754b6b5744SDavid Schultzvaries across machine architectures.
764b6b5744SDavid SchultzIf you understood the innards of a particular platform well enough to
774b6b5744SDavid Schultzknow what string to use, then you would have no need for these functions
784b6b5744SDavid Schultzanyway, so don't use them.
794b6b5744SDavid SchultzUse the
804b6b5744SDavid Schultz.Dv NAN
814b6b5744SDavid Schultzmacro instead.
824b6b5744SDavid Schultz.Sh SEE ALSO
834b6b5744SDavid Schultz.Xr fenv 3 ,
844b6b5744SDavid Schultz.Xr ieee 3 ,
854b6b5744SDavid Schultz.Xr isnan 3 ,
864b6b5744SDavid Schultz.Xr math 3 ,
874b6b5744SDavid Schultz.Xr strtod 3
884b6b5744SDavid Schultz.Sh STANDARDS
894b6b5744SDavid SchultzThe
904b6b5744SDavid Schultz.Fn nan ,
914b6b5744SDavid Schultz.Fn nanf ,
924b6b5744SDavid Schultzand
934b6b5744SDavid Schultz.Fn nanl
944b6b5744SDavid Schultzfunctions and the
954b6b5744SDavid Schultz.Dv NAN
964b6b5744SDavid Schultzmacro conform to
974b6b5744SDavid Schultz.St -isoC-99 .
98