nand32(), nand64(), nand128() — Return quiet NaN
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.8 |
Format
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 nand32(const char *tagp);
_Decimal64 nand64(const char *tagp);
_Decimal128 nand128(const char *tagp);
General description
In the nan() family
of functions, the call nand32("n-char-sequence") is equivalent to
strtod32("NAN(n-charsequence)", (char**) NULL) and the call nand32("")
is equivalent to strtod32("NAN()", (char**) NULL). If tagp does not
point to an n-char sequence or an empty string, the call is equivalent
to strtod32("NAN", (char**) NULL). Calls to nand64() and nand128()
are equivalent to the corresponding calls strtod64() and strtod128().
Notes:
- To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.
- These functions work in IEEE decimal floating-point format. See "IEEE Decimal Floating-Point" for more information.
Returned value
If successful, they return a quiet NaN with content indicated by tagp.
Example
/* CELEBN05
This program illustrates the use of the nand32() function.
It calls both nand32() and strtod32() with equivalent arguments
and displays output of both. Output should be identical.
*/
#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
#include <stdlib.h> /* needed for strtod32() */
#define TESTVALS 5
struct
{
const char * str;
}
nan_vals[] =
{
/*0*/ { "0" },
/*1*/ { "1" },
/*2*/ { "something" }, /* invalid n-char seq. */
/*3*/ { "999999" }, /* max nancode */
/*4*/ { "1000000" } /* max nancode + 1 */
}
,
strod_vals[] =
{
/*0*/ { "NAN(0)" },
/*1*/ { "NAN(1)" },
/*2*/ { "NAN" },
/*3*/ { "NAN(999999)" },
/*4*/ { "NAN(1000000)" }
};
int main(void)
{
_Decimal32 outnan,
outstrtod;
int i;
printf("Illustrates the nand32() function\n");
printf("Output for both nand32() and strtod32()"
"should be identical.\n\n");
for (i = 0; i < TESTVALS; i++)
{
outnan = nand32( nan_vals[i].str );
outstrtod = strtod32(strod_vals[i].str, NULL);
printf("nand32(%s) returned = %Hg\n"
, nan_vals[i].str, outnan );
printf("strtod32(%s) returned = %Hg\n\n"
, strod_vals[i].str, outstrtod);
}
return 0;
}