ppc64: Arguments to iselInt128Expr_to_32x4 should be initialized.
[valgrind.git] / memcheck / tests / vcpu_fnfns.c
blobd9a19e7c802425b59c2ab0903f3945a08560cca2
2 /* Program to check that the FP stuff underlying these common FP
3 functions isn't too badly broken. Carefully kludged to print the
4 same answers on different platforms (even when run natively). */
6 #include <stdio.h>
7 #include <math.h>
9 int main ( void )
11 double d;
12 float f;
13 int i;
15 const double tinyD = 0.0000000001;
16 const double tinyF = 0.0001;
18 /* -------------------- any arg -------------------- */
20 d = -2.0;
21 for (i = 0; i < 41; i++) {
22 printf("floorD(%+20.13e) = %+20.13e\n", d, floor(d));
23 d += 0.1-tinyD;
25 f = -2.0;
26 for (i = 0; i < 41; i++) {
27 printf("floorF(%+20.4e) = %+20.4e\n", (double)f, (double)floorf(f));
28 f += 0.1-tinyF;
32 d = -2.0;
33 for (i = 0; i < 41; i++) {
34 printf(" ceilD(%+20.13e) = %+20.13e\n", d, ceil(d));
35 d += 0.1-tinyD;
37 f = -2.0;
38 for (i = 0; i < 41; i++) {
39 printf(" ceilF(%+20.4e) = %+20.4e\n", (double)f, (double)ceilf(f));
40 f += 0.1-tinyF;
44 d = -2.0;
45 for (i = 0; i < 41; i++) {
46 printf(" sinD(%+20.13e) = %+20.13e\n", d, sin(d));
47 d += 0.1-tinyD;
49 f = -2.0;
50 for (i = 0; i < 41; i++) {
51 printf(" sinF(%+20.4e) = %+20.4e\n", (double)f, (double)sinf(f));
52 f += 0.1-tinyF;
56 d = -2.0;
57 for (i = 0; i < 41; i++) {
58 printf(" cosD(%+20.13e) = %+20.13e\n", d, cos(d));
59 d += 0.1-tinyD;
61 f = -2.0;
62 for (i = 0; i < 41; i++) {
63 printf(" cosF(%+20.4e) = %+20.4e\n", (double)f, (double)cosf(f));
64 f += 0.1-tinyF;
68 d = -2.0;
69 for (i = 0; i < 41; i++) {
70 printf(" tanD(%+20.13e) = %+20.13e\n", d, tan(d));
71 d += 0.1-tinyD;
73 f = -2.0;
74 for (i = 0; i < 41; i++) {
75 printf(" tanF(%+20.4e) = %+20.4e\n", (double)f, (double)tanf(f));
76 f += 0.1-tinyF;
80 d = -2.0;
81 for (i = 0; i < 41; i++) {
82 printf(" expD(%+20.13e) = %+20.13e\n", d, exp(d));
83 d += 0.1-tinyD;
85 f = -2.0;
86 for (i = 0; i < 41; i++) {
87 printf(" expF(%+20.4e) = %+20.4e\n", (double)f, (double)expf(f));
88 f += 0.1-tinyF;
91 /* -------------------- >= 0 arg -------------------- */
93 d = 0.0;
94 for (i = 0; i < 21; i++) {
95 printf(" sqrtD(%+20.13e) = %+20.13e\n", d, sqrt(d));
96 d += 0.1-tinyD;
98 f = 0.0;
99 for (i = 0; i < 21; i++) {
100 printf(" sqrtF(%+20.4e) = %+20.4e\n", (double)f, (double)sqrtf(f));
101 f += 0.1-tinyF;
105 d = 0.0;
106 for (i = 0; i < 21; i++) {
107 printf(" logD(%+20.13e) = %+20.13e\n", d, log(d));
108 d += 0.1-tinyD;
110 f = 0.0;
111 for (i = 0; i < 21; i++) {
112 printf(" logF(%+20.4e) = %+20.4e\n", (double)f, (double)logf(f));
113 f += 0.1-tinyF;
117 d = 0.0;
118 for (i = 0; i < 21; i++) {
119 printf("log10D(%+20.13e) = %+20.13e\n", d, log10(d));
120 d += 0.1-tinyD;
122 f = 0.0;
123 for (i = 0; i < 21; i++) {
124 printf("log10F(%+20.4e) = %+20.4e\n", (double)f, (double)log10f(f));
125 f += 0.1-tinyF;
128 /* -------------------- -1 .. +1 arg -------------------- */
130 d = -1.0;
131 for (i = 0; i < 21; i++) {
132 printf(" asinD(%+20.13e) = %+20.13e\n", d, asin(d));
133 d += 0.1-tinyD;
135 f = -1.0;
136 for (i = 0; i < 21; i++) {
137 printf(" asinF(%+20.4e) = %+20.4e\n", (double)f, (double)asinf(f));
138 f += 0.1-tinyF;
141 /* acos(double) seems very prone to accuracy loss near the end of
142 the range (arg --> +1.0). Hence is different from the rest to
143 stop it getting so close to 1.0. */
144 d = -1.0;
145 for (i = 0; i < 21; i++) {
146 printf(" acosD(%+20.13e) = %+20.10e\n", d, acos(d));
147 d += 0.1 - 1000.0*tinyD;
149 f = -1.0;
150 for (i = 0; i < 21; i++) {
151 printf(" acosF(%+20.4e) = %+20.4e\n", (double)f, (double)acosf(f));
152 f += 0.1-tinyF;
156 d = -1.0;
157 for (i = 0; i < 21; i++) {
158 printf(" atanD(%+20.13e) = %+20.13e\n", d, atan(d));
159 d += 0.1-tinyD;
161 f = -1.0;
162 for (i = 0; i < 21; i++) {
163 printf(" atanF(%+20.4e) = %+20.4e\n", (double)f, (double)atanf(f));
164 f += 0.1-tinyF;
168 d = -1.0;
169 for (i = 0; i < 21; i++) {
170 printf("atan2D(%+20.13e) = %+20.13e\n", d, atan2(d, 1.0));
171 d += 0.1-tinyD;
173 f = -1.0;
174 for (i = 0; i < 21; i++) {
175 printf("atan2F(%+20.4e) = %+20.4e\n", (double)f, (double)atan2f(f,1.0));
176 f += 0.1-tinyF;
179 return 0;