Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
NaN
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Display == Different operating systems and programming languages may have different string representations of NaN. nan (C, C++, Python) NaN (ECMAScript, Rust, C#, Julia, Java). <small>Julia may show alternative NaN, depending on precision, NaN32, and NaN16; NaN is for Float64 type.</small> NaN% NAN (C, C++, Rust) NaNQ (IBM XL and AIX: Fortran, C++ proposal n2290) NaNS (ditto) qNaN sNaN 1.#SNAN (Excel) 1.#QNAN (Excel) -1.#IND (Excel) +nan.0 (Scheme) Since, in practice, encoded NaNs have a sign, a quiet/signaling bit and optional 'diagnostic information' (sometimes called a ''payload''), these will occasionally be found in string representations of NaNs, too. Some examples are: * For the C and C++ languages, the sign bit is always shown by the standard-library functions (e.g. {{code|-nan}}) when present. There is no standard display of the payload nor of the signaling status, but a quiet NaN value of a specific payload may either be constructed by providing the string <code>nan(''char-sequence'')</code> to a number-parsing function (e.g. {{code|strtod}}) or by providing the ''char-sequence'' string to {{code|nan()}} (or {{code|nans()}} for sNaN), both interpreted in an implementation-defined manner. ** [[GNU C Compiler|GCC]] and [[LLVM]] provides built-in implementations of {{code|nan()}} and {{code|nans()}}. They parse the ''char-sequence'' as an integer for {{code|strtoull}} (or a differently-sized equivalent) with its detection of integer bases. ** The [[GNU C Library]]'s float-parser uses the ''char-sequence'' string in "some unspecified fashion".<ref>{{cite web |url=https://www.gnu.org/software/libc/manual/html_node/Parsing-of-Floats.html |title=Parsing of Floats (The GNU C Library) |website=www.gnu.org |access-date=9 September 2021 |quote=If ''chars…'' are provided, they are used in some unspecified fashion to select a particular representation of NaN (there can be several).}}</ref> In practice, this parsing has been equivalent to GCC/LLVM's for up to 64 bits of payload.<!-- bug 28322: stable but undocumented behavior --> ** [[Newlib]] does not implement {{code|nan()}} parsing, but {{code|strtod()}} accepts a hexadecimal format without prefix. ** [[musl]] does not implement any payload parsing. Not all languages admit the existence of multiple NaNs. For example, ECMAScript only uses one NaN value throughout.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
NaN
(section)
Add topic