From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/numeric%2Fmath%2Fnan.html | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 devdocs/c/numeric%2Fmath%2Fnan.html (limited to 'devdocs/c/numeric%2Fmath%2Fnan.html') diff --git a/devdocs/c/numeric%2Fmath%2Fnan.html b/devdocs/c/numeric%2Fmath%2Fnan.html new file mode 100644 index 00000000..b8bdd8b4 --- /dev/null +++ b/devdocs/c/numeric%2Fmath%2Fnan.html @@ -0,0 +1,74 @@ +

nan, nanf, nanl, nand32, nand64, nand128

Defined in header <math.h>
float       nanf( const char* arg );
+
(1) (since C99)
double      nan( const char* arg );
+
(2) (since C99)
long double nanl( const char* arg );
+
(3) (since C99)
_Decimal32  nand32( const char* arg );
+
(4) (since C23)
_Decimal64  nand64( const char* arg );
+
(5) (since C23)
_Decimal128 nand128( const char* arg );
+
(6) (since C23)

Converts the implementation-defined character string arg into the corresponding quiet NaN value, as if by calling the appropriate parsing function strtoX, as follows:

+
+1) The parsing function is strtof.
+2) The parsing function is strtod.
+3) The parsing function is strtold.
+4) The parsing function is strtod32.
+5) The parsing function is strtod64.
+6) The parsing function is strtod128.
+ +

The functions returning decimal floating point values are declared if and only the implementation predefines __STDC_IEC_60559_DFP__ (i.e. the implementation supports decimal floating point numbers).

+
(since C23)

Parameters

+ +
arg - narrow character string identifying the contents of a NaN

Return value

The quiet NaN value that corresponds to the identifying string arg or zero if the implementation does not support quiet NaNs.

+

If the implementation supports IEEE floating-point arithmetic (IEC 60559), it also supports quiet NaNs.

+

Error handling

This function is not subject to any of the error conditions specified in math_errhandling.

+

Example

#include <stdio.h>
+#include <math.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+ 
+int main(void)
+{
+    double f1 = nan("1");
+    uint64_t f1n; memcpy(&f1n, &f1, sizeof f1);
+    printf("nan(\"1\")   = %f (%" PRIx64 ")\n", f1, f1n);
+ 
+    double f2 = nan("2");
+    uint64_t f2n; memcpy(&f2n, &f2, sizeof f2);
+    printf("nan(\"2\")   = %f (%" PRIx64 ")\n", f2, f2n);
+ 
+    double f3 = nan("0xF");
+    uint64_t f3n; memcpy(&f3n, &f3, sizeof f3);
+    printf("nan(\"0xF\") = %f (%" PRIx64 ")\n", f3, f3n);
+}

Possible output:

+
nan("1")   = nan (7ff8000000000001)
+nan("2")   = nan (7ff8000000000002)
+nan("0xF") = nan (7ff800000000000f)

References

See also

+ + +
+
(C99)
checks if the given number is NaN
(function macro)
+
(C99)
evaluates to a quiet NaN of type float
(macro constant)
C++ documentation for nanf, nan, nanl
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/numeric/math/nan +

+
-- cgit v1.2.3