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 volatile DOUBLE x;
34 volatile DOUBLE y;
35 volatile DOUBLE z;
36
37
38 x = MAX;
39 y = MAX * L_(0.5);
40 z = HYPOT (x, y);
41 ASSERT (z == HUGEVAL);
42
43
44 x = MIN;
45 y = L_(0.0);
46 z = HYPOT (x, y);
47 ASSERT (z == MIN);
48
49
50 x = MIN * L_(2.0);
51 y = MIN * L_(3.0);
52 z = HYPOT (x, y);
53 ASSERT (z >= MIN * L_(2.0) && z <= MIN * L_(4.0));
54 }
55
56
57 for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
58 for (j = 0; j < SIZEOF (RANDOM) / 5;j++)
59 {
60 DOUBLE x = L_(16.0) * RANDOM[i];
61 DOUBLE y = L_(16.0) * RANDOM[j];
62 DOUBLE z = HYPOT (x, y);
63 DOUBLE err = z * z - (x * x + y * y);
64 ASSERT (z >= L_(0.0));
65 ASSERT (err >= - L_(4.0) * L_(16.0) * L_(16.0) / TWO_MANT_DIG
66 && err <= L_(4.0) * L_(16.0) * L_(16.0) / TWO_MANT_DIG);
67 }
68 }
69
70 volatile DOUBLE x;
71 volatile DOUBLE y;
72 DOUBLE z;