(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
20020607-2.c
       1  /* Copyright (C) 2002 Free Software Foundation.
       2  
       3     Test for correctness of floating point comparisons.
       4  
       5     Written by Roger Sayle, 3rd June 2002.  */
       6  
       7  /* { dg-do run } */
       8  /* { dg-options "-O2 -ffast-math" } */
       9  
      10  extern void abort (void);
      11  
      12  int test1 (double x, int ok)
      13  {
      14    if ((x - 1.0) > 0.0)
      15      {
      16        if (!ok) abort ();
      17      }
      18    else
      19      if (ok) abort ();
      20  }
      21  
      22  int test1f (float x, int ok)
      23  {
      24    if ((x - 1.0f) > 0.0f)
      25      {
      26        if (!ok) abort ();
      27      }
      28    else
      29      if (ok) abort ();
      30  }
      31  
      32  int test2 (double x, int ok)
      33  {
      34    if ((x + 1.0) < 0.0)
      35      {
      36        if (!ok) abort ();
      37      }
      38    else
      39      if (ok) abort ();
      40  }
      41  
      42  int test2f (float x, int ok)
      43  {
      44    if ((x + 1.0f) < 0.0f)
      45      {
      46        if (!ok) abort ();
      47      }
      48    else
      49      if (ok) abort ();
      50  }
      51  
      52  
      53  int
      54  main ()
      55  {
      56    test1 (-2.0, 0);
      57    test1 ( 0.0, 0);
      58    test1 ( 2.0, 1);
      59  
      60    test1f (-2.0f, 0);
      61    test1f ( 0.0f, 0);
      62    test1f ( 2.0f, 1);
      63  
      64    test2 (-2.0, 1);
      65    test2 ( 0.0, 0);
      66    test2 ( 2.0, 0);
      67  
      68    test2f (-2.0f, 1);
      69    test2f ( 0.0f, 0);
      70    test2f ( 2.0f, 0);
      71  
      72    return 0;
      73  }
      74