1 typedef struct sreal
2 {
3 unsigned sig; /* Significant. */
4 int exp; /* Exponent. */
5 } sreal;
6
sreal_compare(sreal * a,sreal * b)7 sreal_compare (sreal *a, sreal *b)
8 {
9 if (a->exp > b->exp)
10 return 1;
11 if (a->exp < b->exp)
12 return -1;
13 if (a->sig > b->sig)
14 return 1;
15 if (a->sig < b->sig)
16 return -1;
17 return 0;
18 }
19
20 sreal a[] = {
21 { 0, 0 },
22 { 1, 0 },
23 { 0, 1 },
24 { 1, 1 }
25 };
26
main()27 int main()
28 {
29 int i, j;
30 for (i = 0; i <= 3; i++) {
31 for (j = 0; j < 3; j++) {
32 if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();
33 if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();
34 if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();
35 }
36 }
37 return 0;
38 }
39