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 return -(a->sig < b->sig);
16 }
17
18 sreal a[] = {
19 { 0, 0 },
20 { 1, 0 },
21 { 0, 1 },
22 { 1, 1 }
23 };
24
main()25 int main()
26 {
27 int i, j;
28 for (i = 0; i <= 3; i++) {
29 for (j = 0; j < 3; j++) {
30 if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();
31 if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();
32 if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();
33 }
34 }
35 return 0;
36 }
37