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 const DOUBLE TWO_MANT_DIG =
22
23
24
25 (DOUBLE) (1U << ((MANT_DIG - 1) / 5))
26 * (DOUBLE) (1U << ((MANT_DIG - 1 + 1) / 5))
27 * (DOUBLE) (1U << ((MANT_DIG - 1 + 2) / 5))
28 * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5))
29 * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
30
31
32 for (i = 0; i < SIZEOF (RANDOM); i++)
33 {
34 DOUBLE x = RANDOM[i];
35 DOUBLE y;
36 DOUBLE z;
37
38 y = MODF (x, &z);
39 ASSERT (z == L_(0.0));
40 ASSERT (y == x);
41
42 y = MODF (- x, &z);
43 ASSERT (z == L_(0.0));
44 ASSERT (y == - x);
45
46 y = MODF (L_(1.0) + x, &z);
47 ASSERT (z == L_(1.0));
48 y -= x;
49 ASSERT (y >= - L_(1.0) / TWO_MANT_DIG);
50 ASSERT (y <= L_(1.0) / TWO_MANT_DIG);
51
52 y = MODF (- L_(1.0) - x, &z);
53 ASSERT (z == - L_(1.0));
54 y -= - x;
55 ASSERT (y >= - L_(1.0) / TWO_MANT_DIG);
56 ASSERT (y <= L_(1.0) / TWO_MANT_DIG);
57 }
58 }
59
60 volatile DOUBLE x;
61 DOUBLE y;
62 DOUBLE z;