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
18
19 static void
20 test_function (void)
21 {
22 int i;
23 volatile DOUBLE x;
24 volatile DOUBLE y;
25
26
27 {
28 x = L_(0.6);
29 y = LDEXP (x, 0);
30 ASSERT (y >= L_(0.5999999999) && y <= L_(0.6000000001));
31 }
32 {
33 x = L_(0.6);
34 y = LDEXP (x, 1);
35 ASSERT (y >= L_(1.199999999) && y <= L_(1.200000001));
36 }
37 {
38 x = L_(0.6);
39 y = LDEXP (x, -1);
40 ASSERT (y >= L_(0.2999999999) && y <= L_(0.3000000001));
41 }
42
43 {
44 x = NAN;
45 y = LDEXP (x, 0); ASSERT (ISNAN (y));
46 y = LDEXP (x, 5); ASSERT (ISNAN (y));
47 y = LDEXP (x, -5); ASSERT (ISNAN (y));
48 }
49
50 {
51 x = INFINITY;
52 y = LDEXP (x, 0); ASSERT (y == x);
53 y = LDEXP (x, 5); ASSERT (y == x);
54 y = LDEXP (x, -5); ASSERT (y == x);
55 }
56
57 {
58 x = - INFINITY;
59 y = LDEXP (x, 0); ASSERT (y == x);
60 y = LDEXP (x, 5); ASSERT (y == x);
61 y = LDEXP (x, -5); ASSERT (y == x);
62 }
63
64 {
65 x = L_(0.0);
66 y = LDEXP (x, 0); ASSERT (y == x); ASSERT (!signbit (x));
67 y = LDEXP (x, 5); ASSERT (y == x); ASSERT (!signbit (x));
68 y = LDEXP (x, -5); ASSERT (y == x); ASSERT (!signbit (x));
69 }
70
71 {
72 x = MINUS_ZERO;
73 y = LDEXP (x, 0); ASSERT (y == x); ASSERT (signbit (x));
74 y = LDEXP (x, 5); ASSERT (y == x); ASSERT (signbit (x));
75 y = LDEXP (x, -5); ASSERT (y == x); ASSERT (signbit (x));
76 }
77
78 {
79 x = L_(1.73205);
80 y = LDEXP (x, 0); ASSERT (y == x);
81 y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
82 y = LDEXP (x, -5); ASSERT (y == x * L_(0.03125));
83 }
84
85 {
86 x = - L_(20.085536923187667742);
87 y = LDEXP (x, 0); ASSERT (y == x);
88 y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
89 y = LDEXP (x, -5); ASSERT (y == x * L_(0.03125));
90 }
91
92 for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
93 {
94 y = LDEXP (x, 0); ASSERT (y == x);
95 {
96 volatile DOUBLE expected;
97 y = LDEXP (x, 5);
98 expected = x * L_(32.0);
99 ASSERT (y == expected);
100 }
101 y = LDEXP (x, -5); ASSERT (y == x * 0.03125L);
102 }
103 for (i = 1, x = L_(1.73205); i >= MIN_EXP; i--, x *= L_(0.5))
104 {
105 y = LDEXP (x, 0); ASSERT (y == x);
106 y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
107 if (i - 5 >= MIN_EXP)
108 {
109 y = LDEXP (x, -5); ASSERT (y == x * L_(0.03125));
110 }
111 }
112 for (; i >= LDBL_MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
113 {
114 y = LDEXP (x, 0); ASSERT (y == x);
115 y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
116 }
117
118
119 for (i = 0; i < SIZEOF (RANDOM); i++)
120 {
121 int u, v;
122
123 x = L_(20.0) * RANDOM[i] - L_(10.0);
124
125
126 for (u = -10; u <= 10; u++)
127 for (v = -10; v <= 10; v++)
128 ASSERT (LDEXP (x, u + v) == LDEXP (LDEXP (x, u), v));
129 }
130 }