int main()
{
  /* An finite 32-bits decimal floating point.  */
  d32 = 1.2345df;		/* Initialize d32.  */

  /* Non-finite 32-bits decimal floating point: infinity and NaN.  */
  d32 = __builtin_infd32();	/* Positive infd32.  */
  d32 = -__builtin_infd32();	/* Negative infd32.  */
  d32 = __builtin_nand32("");

  /* An finite 64-bits decimal floating point.  */
  d64 = 1.2345dd;		/* Initialize d64.  */

  /* Non-finite 64-bits decimal floating point: infinity and NaN.  */
  d64 = __builtin_infd64();	/* Positive infd64.  */
  d64 = -__builtin_infd64();	/* Negative infd64.  */
  d64 = __builtin_nand64("");

  /* An finite 128-bits decimal floating point.  */
  d128 = 1.2345dl;		/* Initialize d128.  */

  /* Non-finite 128-bits decimal floating point: infinity and NaN.  */
  d128 = __builtin_infd128();	/* Positive infd128.  */
  d128 = -__builtin_infd128();	/* Negative infd128.  */
  d128 = __builtin_nand128("");

  /* Functions with decimal floating point as parameter and return value. */
  d32 = arg0_32 (0.1df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df);
  d64 = arg0_64 (0.1dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd);
  d128 = arg0_128 (0.1dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl);

  ds.int4 = 1;
  ds.long8 = 2;
  ds.float4 = 3.1;
  ds.double8 = 4.2;
  ds.dec32 = 1.2345df;
  ds.dec64 = 1.2345dd;
  ds.dec128 = 1.2345dl;

  return 0;	/* Exit point.  */
}
Ejemplo n.º 2
0
int main()
{
  /* Some possibly non-obvious tests, but most logical
     operations on NaN return false, including NaN == NaN. */
  if (__builtin_nand32("") == __builtin_nand32(""))
    abort();

  if (__builtin_nand64("") == __builtin_nand64(""))
    abort();

  if (__builtin_nand128("") == __builtin_nand128(""))
    abort();
  
  if (!(__builtin_nand32("") != __builtin_nand32("")))
    abort();

  if (!(__builtin_nand64("") != __builtin_nand64("")))
    abort();

  if (!(__builtin_nand128("") != __builtin_nand128("")))
    abort();

  if (__builtin_nand32("") > __builtin_nand32(""))
    abort();

  if (__builtin_nand64("") >= __builtin_nand64(""))
    abort();

  if (__builtin_nand128("") <  __builtin_nand128(""))
    abort();

  if (-__builtin_nand128("") <  +__builtin_nand128(""))
    abort();

  /* 0.0/0.0 => NaN, but NaN != NaN.  */
  if (0.0df/0.0dl == __builtin_nand32(""))
    abort();

  /* 0.0 * INF => NaN.  */
  if (!__builtin_isnand32 (0.0df * __builtin_infd32()))
    abort ();

  if (!__builtin_isnand64 (0.0dd * __builtin_infd64()))
    abort ();

  if (!__builtin_isnand128 (0.0dd * __builtin_infd128()))
    abort ();

  /* INF - INF => NaN.  */
  if (!__builtin_isnand32 (__builtin_infd32() - __builtin_infd32()))
    abort ();

  if (!__builtin_isnand64 (__builtin_infd64() - __builtin_infd64()))
    abort ();

  if (!__builtin_isnand128 (__builtin_infd128() - __builtin_infd128()))
    abort ();

  /* INF/INF => NaN.  */
  if (!__builtin_isnand32 (__builtin_infd32()/__builtin_infd32()) )
    abort ();

  if (!__builtin_isnand64 (__builtin_infd64()/__builtin_infd64()) )
    abort ();

  if (!__builtin_isnand128 (__builtin_infd128()/__builtin_infd128()) )
    abort ();
  
  /* 0.0/0.0 => NaN, but NaN != NaN.  */
  if ((0.0dd/0.0df) == (0.0dd/0.0df))
    abort();

  if (__builtin_nand32("") <  __builtin_infd32())
    abort();

  if (__builtin_nand32("") >=  __builtin_infd32())
    abort();

  /* Fixme: Add sqrtdf(-x.df) test when sqrt is supported. */

  if (!__builtin_isnand32(__builtin_nand32("")))
    abort();

  if (!__builtin_isnand64(__builtin_nand64("")))
    abort();

  if (!__builtin_isnand128(__builtin_nand128("")))
    abort();

  if (!__builtin_isnand128(8.0df * __builtin_nand128("")))
    abort();

  if (!__builtin_isnand32(8.1dl - __builtin_nand32("")))
    abort();

  if (!__builtin_isnand128(__builtin_nand64("") + __builtin_nand128("")))
    abort();

  return 0;
}
Ejemplo n.º 3
0

typedef struct
{
  int line;
  _Decimal64 d;
  const char *expect;
} d64_type;

static const
d64_type d64[] =
{
  {__LINE__, 1.00DD,                  "+0,000,000,000,000,100E-2"},
  {__LINE__, __DEC64_MIN__,           "+0,000,000,000,000,001E-383"},
  {__LINE__, __DEC64_MAX__,           "+9,999,999,999,999,999E+369"},
  {__LINE__, -__builtin_nand64(""),   "-0,000,000,000,000,000E-398"},
  {__LINE__,  __builtin_infd64(),     "+0,000,000,000,000,000E-398"},
  {__LINE__, 9.999999999999999E369DD, "+9,999,999,999,999,999E+354"},
  {__LINE__, 9.999999999999999E370DD, "+9,999,999,999,999,999E+355"},
  {__LINE__, 9.999999999999999E384DD, "+9,999,999,999,999,999E+369"},
  {__LINE__, __DEC64_MIN__,           "+0,000,000,000,000,001E-383"},
  {__LINE__, __DEC64_SUBNORMAL_MIN__, "+0,000,000,000,000,001E-398"},
  {__LINE__, 1E-398DD,                "+0,000,000,000,000,001E-398"},
  {__LINE__, 9E370DD,                 "+0,000,000,000,000,090E+369"},
  {__LINE__, 4E384DD,                 "+4,000,000,000,000,000E+369"},
};
static const int d64s = sizeof (d64) / sizeof (d64[0]);


typedef struct
{