aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/torture/float128-truncdf-underflow.c
blob: 83b05387ea002fd5ac6156206c88b8cfae3ad4ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Test truncation from __float128 to double uses after-rounding
   tininess detection.  */

/* { dg-do run { target i?86-*-* x86_64-*-* ia64-*-* } } */
/* { dg-options "" } */
/* { dg-require-effective-target fenv_exceptions } */

#include <fenv.h>
#include <stdlib.h>

int
main (void)
{
  volatile __float128 a = 0x0.fffffffffffffffp-1022q, b = 0x0.fffffffffffff8p-1022q;
  volatile double r;
  r = (double) a;
  if (fetestexcept (FE_UNDERFLOW))
    abort ();
  if (r != 0x1p-1022)
    abort ();
  r = (double) b;
  if (!fetestexcept (FE_UNDERFLOW))
    abort ();
  if (r != 0x1p-1022)
    abort ();
  exit (0);
}