Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.8 |
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 nand32(const char *tagp);
_Decimal64 nand64(const char *tagp);
_Decimal128 nand128(const char *tagp);
If successful, they return a quiet NaN with content indicated by tagp.
⁄* 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;
}