This source file includes following definitions.
- test_function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 static void
18 test_function (void)
19 {
20 int i;
21 int j;
22 const DOUBLE TWO_MANT_DIG =
23
24
25
26 (DOUBLE) (1U << ((MANT_DIG - 1) / 5))
27 * (DOUBLE) (1U << ((MANT_DIG - 1 + 1) / 5))
28 * (DOUBLE) (1U << ((MANT_DIG - 1 + 2) / 5))
29 * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5))
30 * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
31
32
33 ASSERT (LOG2 (L_(0.0)) == - HUGEVAL);
34 ASSERT (LOG2 (MINUS_ZERO) == - HUGEVAL);
35
36
37 {
38 DOUBLE x = L_(1.0);
39 DOUBLE y = LOG2 (x);
40 ASSERT (y == L_(0.0));
41 }
42 {
43 int e;
44 DOUBLE x;
45 DOUBLE y;
46 for (e = 0, x = L_(0.0), y = L_(1.0);
47 e <= MAX_EXP - 1;
48 e++, x = x + L_(1.0), y = y * L_(2.0))
49 {
50
51 DOUBLE z = LOG2 (y);
52 ASSERT (z == x);
53 }
54 }
55 {
56 int e;
57 DOUBLE x;
58 DOUBLE y;
59 for (e = 0, x = L_(0.0), y = L_(1.0);
60 e >= MIN_EXP - 1;
61 e--, x = x - L_(1.0), y = y * L_(0.5))
62 {
63
64 DOUBLE z = LOG2 (y);
65 ASSERT (z == x);
66 }
67 }
68
69
70 {
71
72 const DOUBLE err_bound =
73 (sizeof (DOUBLE) > sizeof (double) ?
74 #if defined __i386__ && defined __FreeBSD__
75
76
77
78
79
80 L_(8193.0)
81 #else
82 L_(5.0)
83 #endif
84 : L_(5.0));
85
86 for (i = 0; i < SIZEOF (RANDOM); i++)
87 {
88 DOUBLE x = L_(16.0) * RANDOM[i] + L_(1.0);
89 DOUBLE y = LOG2 (x);
90 DOUBLE z = LOG2 (L_(1.0) / x);
91 DOUBLE err = y + z;
92 ASSERT (y >= L_(0.0));
93 ASSERT (z <= L_(0.0));
94 ASSERT (err > - err_bound / TWO_MANT_DIG
95 && err < err_bound / TWO_MANT_DIG);
96 }
97 }
98
99 {
100
101 const DOUBLE err_bound =
102 (sizeof (DOUBLE) > sizeof (double) ?
103 #if defined __i386__ && defined __FreeBSD__
104
105
106
107
108
109 L_(8193.0)
110 #else
111 L_(9.0)
112 #endif
113 : L_(9.0));
114
115 for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
116 for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
117 {
118 DOUBLE x = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[i]) - L_(1.0);
119 DOUBLE y = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[j]) - L_(1.0);
120
121 DOUBLE z = L_(1.0) / (x * y);
122
123 DOUBLE err = LOG2 (x) + LOG2 (y) + LOG2 (z);
124 ASSERT (err > - err_bound / TWO_MANT_DIG
125 && err < err_bound / TWO_MANT_DIG);
126 }
127 }
128 }
129
130 volatile DOUBLE x;
131 DOUBLE y;