aboutsummaryrefslogtreecommitdiff
path: root/libgloss/testsuite/libgloss.all/div.c
blob: 32eff9d4d0755396675b2aa3321426a5e7dc3bb2 (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
28
29
30
31
32
33
34
35
/* WinBond bug report

   Please don't use "gcc -O3 -S hello.c" command, because it
   will optimize "i/5" to be "2" in compile time.

 */

#include <stdio.h>
#define TESTSEED 10

main ()
{
  int    a1,b1,c1;
  long   a2,b2,c2;
  double a3,b3,c3;
  float  a4,b4,c4;
  char   buf[20];

  /* integer tests */
  for (a1 = 1; a1 < 16; a1++) {
    b1 = TESTSEED/a1;
    c1 = TESTSEED%a1;
    printf ("%d/%d = %d, ^ = %d\n", TESTSEED, a1, b1, c1);
    if ((c1 + (a1 * b1)) == TESTSEED) {
      sprintf (buf, "div %d by %d", TESTSEED, a1);
      pass (buf);      
    } else {
      sprintf (buf, "div %d by %d", TESTSEED, a1);
      fail (buf);
    }
    fflush (stdout);
  }
}