This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include <math.h>
22
23 #include "signature.h"
24 SIGNATURE_CHECK (copysignf, float, (float, float));
25
26 #include "macros.h"
27 #include "minus-zero.h"
28
29 #include <string.h>
30
31 volatile float x;
32 volatile float y;
33 float z;
34 float zero = 0.0f;
35
36 int
37 main ()
38 {
39
40 x = 0.6f;
41 y = 0.8f;
42 z = copysignf (x, y);
43 ASSERT (z == 0.6f);
44
45
46 x = -0.6f;
47 y = 0.8f;
48 z = copysignf (x, y);
49 ASSERT (z == 0.6f);
50
51
52 x = -0.6f;
53 y = -0.8f;
54 z = copysignf (x, y);
55 ASSERT (z == -0.6f);
56
57
58 x = 0.6f;
59 y = -0.8f;
60 z = copysignf (x, y);
61 ASSERT (z == -0.6f);
62
63
64 x = 1.0f;
65 y = 0.0f;
66 z = copysignf (x, y);
67 ASSERT (z == 1.0f);
68
69 x = 1.0f;
70 y = minus_zerof;
71 z = copysignf (x, y);
72
73 ASSERT (z == -1.0f);
74
75 x = -1.0f;
76 y = 0.0f;
77 z = copysignf (x, y);
78 ASSERT (z == 1.0f);
79
80 x = -1.0f;
81 y = minus_zerof;
82 z = copysignf (x, y);
83 ASSERT (z == -1.0f);
84
85
86 x = 0.0f;
87 y = 1.0f;
88 z = copysignf (x, y);
89 ASSERT (z == 0.0f);
90 ASSERT (memcmp (&z, &zero, sizeof z) == 0);
91
92 x = 0.0f;
93 y = -1.0f;
94 z = copysignf (x, y);
95 ASSERT (z == 0.0f);
96 ASSERT (memcmp (&z, &zero, sizeof z) != 0);
97
98 x = minus_zerof;
99 y = 1.0f;
100 z = copysignf (x, y);
101 ASSERT (z == 0.0f);
102 ASSERT (memcmp (&z, &zero, sizeof z) == 0);
103
104 x = minus_zerof;
105 y = -1.0f;
106 z = copysignf (x, y);
107 ASSERT (z == 0.0f);
108 ASSERT (memcmp (&z, &zero, sizeof z) != 0);
109
110 return 0;
111 }