xref: /netbsd-src/tests/lib/libm/t_pow.c (revision ba65fde2d7fefa7d39838fa5fa855e62bd606b5e)
1 /* $NetBSD: t_pow.c,v 1.2 2011/09/23 13:48:28 jruoho Exp $ */
2 
3 /*-
4  * Copyright (c) 2011 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jukka Ruohonen.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: t_pow.c,v 1.2 2011/09/23 13:48:28 jruoho Exp $");
33 
34 #include <atf-c.h>
35 #include <math.h>
36 
37 /*
38  * pow(3)
39  */
40 ATF_TC(pow_nan_x);
41 ATF_TC_HEAD(pow_nan_x, tc)
42 {
43 	atf_tc_set_md_var(tc, "descr", "Test pow(NaN, y) == NaN");
44 }
45 
46 ATF_TC_BODY(pow_nan_x, tc)
47 {
48 #ifndef __vax__
49 	const double x = 0.0L / 0.0L;
50 
51 	ATF_CHECK(isnan(pow(x, 2.0)) != 0);
52 #endif
53 }
54 
55 ATF_TC(pow_nan_y);
56 ATF_TC_HEAD(pow_nan_y, tc)
57 {
58 	atf_tc_set_md_var(tc, "descr", "Test pow(x, NaN) == NaN");
59 }
60 
61 ATF_TC_BODY(pow_nan_y, tc)
62 {
63 #ifndef __vax__
64 	const double y = 0.0L / 0.0L;
65 
66 	ATF_CHECK(isnan(pow(2.0, y)) != 0);
67 #endif
68 }
69 
70 ATF_TC(pow_inf_neg_x);
71 ATF_TC_HEAD(pow_inf_neg_x, tc)
72 {
73 	atf_tc_set_md_var(tc, "descr", "Test pow(-Inf, y) == +-Inf || +-0.0");
74 }
75 
76 ATF_TC_BODY(pow_inf_neg_x, tc)
77 {
78 #ifndef __vax__
79 	const double x = -1.0L / 0.0L;
80 	double z;
81 
82 	/*
83 	 * If y is odd, y > 0, and x is -Inf, -Inf is returned.
84 	 * If y is even, y > 0, and x is -Inf, +Inf is returned.
85 	 */
86 	z = pow(x, 3.0);
87 
88 	if (isinf(z) == 0 || signbit(z) == 0)
89 		atf_tc_fail_nonfatal("pow(-Inf, 3.0) != -Inf");
90 
91 	z = pow(x, 4.0);
92 
93 	if (isinf(z) == 0 || signbit(z) != 0)
94 		atf_tc_fail_nonfatal("pow(-Inf, 4.0) != +Inf");
95 
96 	/*
97 	 * If y is odd, y < 0, and x is -Inf, -0.0 is returned.
98 	 * If y is even, y < 0, and x is -Inf, +0.0 is returned.
99 	 */
100 	z = pow(x, -3.0);
101 
102 	if (fabs(z) > 0.0 || signbit(z) == 0)
103 		atf_tc_fail_nonfatal("pow(-Inf, -3.0) != -0.0");
104 
105 	z = pow(x, -4.0);
106 
107 	if (fabs(z) > 0.0 || signbit(z) != 0)
108 		atf_tc_fail_nonfatal("pow(-Inf -4.0) != +0.0");
109 #endif
110 }
111 
112 ATF_TC(pow_inf_neg_y);
113 ATF_TC_HEAD(pow_inf_neg_y, tc)
114 {
115 	atf_tc_set_md_var(tc, "descr", "Test pow(x, -Inf) == +Inf || +0.0");
116 }
117 
118 ATF_TC_BODY(pow_inf_neg_y, tc)
119 {
120 #ifndef __vax__
121 	const double y = -1.0L / 0.0L;
122 	double z;
123 
124 	/*
125 	 * If |x| < 1 and y is -Inf, +Inf is returned.
126 	 * If |x| > 1 and y is -Inf, +0.0 is returned.
127 	 */
128 	z = pow(0.1, y);
129 
130 	if (isinf(z) == 0 || signbit(z) != 0)
131 		atf_tc_fail_nonfatal("pow(0.1, -Inf) != +Inf");
132 
133 	z = pow(1.1, y);
134 
135 	if (fabs(z) > 0.0 || signbit(z) != 0)
136 		atf_tc_fail_nonfatal("pow(1.1, -Inf) != +0.0");
137 #endif
138 }
139 
140 ATF_TC(pow_inf_pos_x);
141 ATF_TC_HEAD(pow_inf_pos_x, tc)
142 {
143 	atf_tc_set_md_var(tc, "descr", "Test pow(+Inf, y) == +Inf || +0.0");
144 }
145 
146 ATF_TC_BODY(pow_inf_pos_x, tc)
147 {
148 #ifndef __vax__
149 	const double x = 1.0L / 0.0L;
150 	double z;
151 
152 	/*
153 	 * For y < 0, if x is +Inf, +0.0 is returned.
154 	 * For y > 0, if x is +Inf, +Inf is returned.
155 	 */
156 	z = pow(x, -2.0);
157 
158 	if (fabs(z) > 0.0 || signbit(z) != 0)
159 		atf_tc_fail_nonfatal("pow(+Inf, -2.0) != +0.0");
160 
161 	z = pow(x, 2.0);
162 
163 	if (isinf(z) == 0 || signbit(z) != 0)
164 		atf_tc_fail_nonfatal("pow(+Inf, 2.0) != +Inf");
165 #endif
166 }
167 
168 ATF_TC(pow_inf_pos_y);
169 ATF_TC_HEAD(pow_inf_pos_y, tc)
170 {
171 	atf_tc_set_md_var(tc, "descr", "Test pow(x, +Inf) == +Inf || +0.0");
172 }
173 
174 ATF_TC_BODY(pow_inf_pos_y, tc)
175 {
176 #ifndef __vax__
177 	const double y = 1.0L / 0.0L;
178 	double z;
179 
180 	/*
181 	 * If |x| < 1 and y is +Inf, +0.0 is returned.
182 	 * If |x| > 1 and y is +Inf, +Inf is returned.
183 	 */
184 	z = pow(0.1, y);
185 
186 	if (fabs(z) > 0.0 || signbit(z) != 0)
187 		atf_tc_fail_nonfatal("pow(0.1, +Inf) != +0.0");
188 
189 	z = pow(1.1, y);
190 
191 	if (isinf(z) == 0 || signbit(z) != 0)
192 		atf_tc_fail_nonfatal("pow(1.1, +Inf) != +Inf");
193 #endif
194 }
195 
196 ATF_TC(pow_one_neg_x);
197 ATF_TC_HEAD(pow_one_neg_x, tc)
198 {
199 	atf_tc_set_md_var(tc, "descr", "Test pow(-1.0, +-Inf) == 1.0");
200 }
201 
202 ATF_TC_BODY(pow_one_neg_x, tc)
203 {
204 #ifndef __vax__
205 	const double infp = 1.0L / 0.0L;
206 	const double infn = -1.0L / 0.0L;
207 
208 	/*
209 	 * If x is -1.0, and y is +-Inf, 1.0 shall be returned.
210 	 */
211 	ATF_REQUIRE(isinf(infp) != 0);
212 	ATF_REQUIRE(isinf(infn) != 0);
213 
214 	if (pow(-1.0, infp) != 1.0) {
215 		atf_tc_expect_fail("PR lib/45372");
216 		atf_tc_fail_nonfatal("pow(-1.0, +Inf) != 1.0");
217 	}
218 
219 	if (pow(-1.0, infn) != 1.0) {
220 		atf_tc_expect_fail("PR lib/45372");
221 		atf_tc_fail_nonfatal("pow(-1.0, -Inf) != 1.0");
222 	}
223 #endif
224 }
225 
226 ATF_TC(pow_one_pos_x);
227 ATF_TC_HEAD(pow_one_pos_x, tc)
228 {
229 	atf_tc_set_md_var(tc, "descr", "Test pow(1.0, y) == 1.0");
230 }
231 
232 ATF_TC_BODY(pow_one_pos_x, tc)
233 {
234 #ifndef __vax__
235 	const double y[] = { 0.0, 0.1, 2.0, -3.0, 99.0, 99.99, 9999999.9 };
236 	const double z = 0.0L / 0.0L;
237 	size_t i;
238 
239 	/*
240 	 * For any value of y (including NaN),
241 	 * if x is 1.0, 1.0 shall be returned.
242 	 */
243 	if (pow(1.0, z) != 1.0)
244 		atf_tc_fail_nonfatal("pow(1.0, NaN) != 1.0");
245 
246 	for (i = 0; i < __arraycount(y); i++) {
247 
248 		if (pow(1.0, y[i]) != 1.0)
249 			atf_tc_fail_nonfatal("pow(1.0, %0.01f) != 1.0", y[i]);
250 	}
251 #endif
252 }
253 
254 ATF_TC(pow_zero_x);
255 ATF_TC_HEAD(pow_zero_x, tc)
256 {
257 	atf_tc_set_md_var(tc, "descr", "Test pow(+-0.0, y) == +-0.0 || HUGE");
258 }
259 
260 ATF_TC_BODY(pow_zero_x, tc)
261 {
262 #ifndef __vax__
263 	double z;
264 
265 	/*
266 	 * If x is +0.0 or -0.0, y > 0, and y
267 	 * is an odd integer, x is returned.
268 	 */
269 	z = pow(+0.0, 3.0);
270 
271 	if (fabs(z) > 0.0 || signbit(z) != 0)
272 		atf_tc_fail_nonfatal("pow(+0.0, 3.0) != +0.0");
273 
274 	z = pow(-0.0, 3.0);
275 
276 	if (fabs(z) > 0.0 || signbit(z) == 0)
277 		atf_tc_fail_nonfatal("pow(-0.0, 3.0) != -0.0");
278 
279 	/*
280 	 * If y > 0 and not an odd integer,
281 	 * if x is +0.0 or -0.0, +0.0 is returned.
282 	 */
283 	z = pow(+0.0, 4.0);
284 
285 	if (fabs(z) > 0.0 || signbit(z) != 0)
286 		atf_tc_fail_nonfatal("pow(+0.0, 4.0) != +0.0");
287 
288 	z = pow(-0.0, 4.0);
289 
290 	if (fabs(z) > 0.0 || signbit(z) != 0)
291 		atf_tc_fail_nonfatal("pow(-0.0, 4.0) != +0.0");
292 
293 	/*
294 	 * If y < 0 and x is +0.0 or -0.0, either +-HUGE_VAL,
295 	 * +-HUGE_VALF, or +-HUGE_VALL shall be returned.
296 	 */
297 	z = pow(+0.0, -4.0);
298 
299 	if (z != HUGE_VAL) {
300 		atf_tc_expect_fail("PR port-amd64/45391");
301 		atf_tc_fail_nonfatal("pow(+0.0, -4.0) != HUGE_VAL");
302 	}
303 
304 	z = pow(-0.0, -4.0);
305 
306 	if (z != HUGE_VAL) {
307 		atf_tc_expect_fail("PR port-amd64/45391");
308 		atf_tc_fail_nonfatal("pow(-0.0, -4.0) != HUGE_VAL");
309 	}
310 
311 	z = pow(+0.0, -5.0);
312 
313 	if (z != HUGE_VAL) {
314 		atf_tc_expect_fail("PR port-amd64/45391");
315 		atf_tc_fail_nonfatal("pow(+0.0, -5.0) != HUGE_VAL");
316 	}
317 
318 	z = pow(-0.0, -5.0);
319 
320 	if (z != -HUGE_VAL)
321 		atf_tc_fail_nonfatal("pow(-0.0, -5.0) != -HUGE_VAL");
322 #endif
323 }
324 
325 ATF_TC(pow_zero_y);
326 ATF_TC_HEAD(pow_zero_y, tc)
327 {
328 	atf_tc_set_md_var(tc, "descr", "Test pow(x, +-0.0) == 1.0");
329 }
330 
331 ATF_TC_BODY(pow_zero_y, tc)
332 {
333 #ifndef __vax__
334 	const double x[] =  { 0.1, -3.0, 77.0, 99.99, 101.0000001 };
335 	const double z = 0.0L / 0.0L;
336 	size_t i;
337 
338 	/*
339 	 * For any value of x (including NaN),
340 	 * if y is +0.0 or -0.0, 1.0 is returned.
341 	 */
342 	if (pow(z, +0.0) != 1.0)
343 		atf_tc_fail_nonfatal("pow(NaN, +0.0) != 1.0");
344 
345 	if (pow(z, -0.0) != 1.0)
346 		atf_tc_fail_nonfatal("pow(NaN, -0.0) != 1.0");
347 
348 	for (i = 0; i < __arraycount(x); i++) {
349 
350 		if (pow(x[i], +0.0) != 1.0)
351 			atf_tc_fail_nonfatal("pow(%0.01f, +0.0) != 1.0", x[i]);
352 
353 		if (pow(x[i], -0.0) != 1.0)
354 			atf_tc_fail_nonfatal("pow(%0.01f, -0.0) != 1.0", x[i]);
355 	}
356 #endif
357 }
358 
359 /*
360  * powf(3)
361  */
362 ATF_TC(powf_nan_x);
363 ATF_TC_HEAD(powf_nan_x, tc)
364 {
365 	atf_tc_set_md_var(tc, "descr", "Test powf(NaN, y) == NaN");
366 }
367 
368 ATF_TC_BODY(powf_nan_x, tc)
369 {
370 #ifndef __vax__
371 	const float x = 0.0L / 0.0L;
372 
373 	ATF_CHECK(isnanf(powf(x, 2.0)) != 0);
374 #endif
375 }
376 
377 ATF_TC(powf_nan_y);
378 ATF_TC_HEAD(powf_nan_y, tc)
379 {
380 	atf_tc_set_md_var(tc, "descr", "Test powf(x, NaN) == NaN");
381 }
382 
383 ATF_TC_BODY(powf_nan_y, tc)
384 {
385 #ifndef __vax__
386 	const float y = 0.0L / 0.0L;
387 
388 	ATF_CHECK(isnanf(powf(2.0, y)) != 0);
389 #endif
390 }
391 
392 ATF_TC(powf_inf_neg_x);
393 ATF_TC_HEAD(powf_inf_neg_x, tc)
394 {
395 	atf_tc_set_md_var(tc, "descr", "Test powf(-Inf, y) == +-Inf || +-0.0");
396 }
397 
398 ATF_TC_BODY(powf_inf_neg_x, tc)
399 {
400 #ifndef __vax__
401 	const float x = -1.0L / 0.0L;
402 	float z;
403 
404 	/*
405 	 * If y is odd, y > 0, and x is -Inf, -Inf is returned.
406 	 * If y is even, y > 0, and x is -Inf, +Inf is returned.
407 	 */
408 	z = powf(x, 3.0);
409 
410 	if (isinff(z) == 0 || signbit(z) == 0)
411 		atf_tc_fail_nonfatal("powf(-Inf, 3.0) != -Inf");
412 
413 	z = powf(x, 4.0);
414 
415 	if (isinff(z) == 0 || signbit(z) != 0)
416 		atf_tc_fail_nonfatal("powf(-Inf, 4.0) != +Inf");
417 
418 	/*
419 	 * If y is odd, y < 0, and x is -Inf, -0.0 is returned.
420 	 * If y is even, y < 0, and x is -Inf, +0.0 is returned.
421 	 */
422 	z = powf(x, -3.0);
423 
424 	if (fabsf(z) > 0.0 || signbit(z) == 0) {
425 		atf_tc_expect_fail("PR lib/45372");
426 		atf_tc_fail_nonfatal("powf(-Inf, -3.0) != -0.0");
427 	}
428 
429 	z = powf(x, -4.0);
430 
431 	if (fabsf(z) > 0.0 || signbit(z) != 0)
432 		atf_tc_fail_nonfatal("powf(-Inf -4.0) != +0.0");
433 #endif
434 }
435 
436 ATF_TC(powf_inf_neg_y);
437 ATF_TC_HEAD(powf_inf_neg_y, tc)
438 {
439 	atf_tc_set_md_var(tc, "descr", "Test powf(x, -Inf) == +Inf || +0.0");
440 }
441 
442 ATF_TC_BODY(powf_inf_neg_y, tc)
443 {
444 #ifndef __vax__
445 	const float y = -1.0L / 0.0L;
446 	float z;
447 
448 	/*
449 	 * If |x| < 1 and y is -Inf, +Inf is returned.
450 	 * If |x| > 1 and y is -Inf, +0.0 is returned.
451 	 */
452 	z = powf(0.1, y);
453 
454 	if (isinff(z) == 0 || signbit(z) != 0)
455 		atf_tc_fail_nonfatal("powf(0.1, -Inf) != +Inf");
456 
457 	z = powf(1.1, y);
458 
459 	if (fabsf(z) > 0.0 || signbit(z) != 0)
460 		atf_tc_fail_nonfatal("powf(1.1, -Inf) != +0.0");
461 #endif
462 }
463 
464 ATF_TC(powf_inf_pos_x);
465 ATF_TC_HEAD(powf_inf_pos_x, tc)
466 {
467 	atf_tc_set_md_var(tc, "descr", "Test powf(+Inf, y) == +Inf || +0.0");
468 }
469 
470 ATF_TC_BODY(powf_inf_pos_x, tc)
471 {
472 #ifndef __vax__
473 	const float x = 1.0L / 0.0L;
474 	float z;
475 
476 	/*
477 	 * For y < 0, if x is +Inf, +0.0 is returned.
478 	 * For y > 0, if x is +Inf, +Inf is returned.
479 	 */
480 	z = powf(x, -2.0);
481 
482 	if (fabsf(z) > 0.0 || signbit(z) != 0)
483 		atf_tc_fail_nonfatal("powf(+Inf, -2.0) != +0.0");
484 
485 	z = powf(x, 2.0);
486 
487 	if (isinff(z) == 0 || signbit(z) != 0)
488 		atf_tc_fail_nonfatal("powf(+Inf, 2.0) != +Inf");
489 #endif
490 }
491 
492 ATF_TC(powf_inf_pos_y);
493 ATF_TC_HEAD(powf_inf_pos_y, tc)
494 {
495 	atf_tc_set_md_var(tc, "descr", "Test powf(x, +Inf) == +Inf || +0.0");
496 }
497 
498 ATF_TC_BODY(powf_inf_pos_y, tc)
499 {
500 #ifndef __vax__
501 	const float y = 1.0L / 0.0L;
502 	float z;
503 
504 	/*
505 	 * If |x| < 1 and y is +Inf, +0.0 is returned.
506 	 * If |x| > 1 and y is +Inf, +Inf is returned.
507 	 */
508 	z = powf(0.1, y);
509 
510 	if (fabsf(z) > 0.0 || signbit(z) != 0)
511 		atf_tc_fail_nonfatal("powf(0.1, +Inf) != +0.0");
512 
513 	z = powf(1.1, y);
514 
515 	if (isinff(z) == 0 || signbit(z) != 0)
516 		atf_tc_fail_nonfatal("powf(1.1, +Inf) != +Inf");
517 #endif
518 }
519 
520 ATF_TC(powf_one_neg_x);
521 ATF_TC_HEAD(powf_one_neg_x, tc)
522 {
523 	atf_tc_set_md_var(tc, "descr", "Test powf(-1.0, +-Inf) == 1.0");
524 }
525 
526 ATF_TC_BODY(powf_one_neg_x, tc)
527 {
528 #ifndef __vax__
529 	const float infp = 1.0L / 0.0L;
530 	const float infn = -1.0L / 0.0L;
531 
532 	/*
533 	 * If x is -1.0, and y is +-Inf, 1.0 shall be returned.
534 	 */
535 	ATF_REQUIRE(isinff(infp) != 0);
536 	ATF_REQUIRE(isinff(infn) != 0);
537 
538 	if (powf(-1.0, infp) != 1.0) {
539 		atf_tc_expect_fail("PR lib/45372");
540 		atf_tc_fail_nonfatal("powf(-1.0, +Inf) != 1.0");
541 	}
542 
543 	if (powf(-1.0, infn) != 1.0) {
544 		atf_tc_expect_fail("PR lib/45372");
545 		atf_tc_fail_nonfatal("powf(-1.0, -Inf) != 1.0");
546 	}
547 #endif
548 }
549 
550 ATF_TC(powf_one_pos_x);
551 ATF_TC_HEAD(powf_one_pos_x, tc)
552 {
553 	atf_tc_set_md_var(tc, "descr", "Test powf(1.0, y) == 1.0");
554 }
555 
556 ATF_TC_BODY(powf_one_pos_x, tc)
557 {
558 #ifndef __vax__
559 	const float y[] = { 0.0, 0.1, 2.0, -3.0, 99.0, 99.99, 9999999.9 };
560 	const float z = 0.0L / 0.0L;
561 	size_t i;
562 
563 	/*
564 	 * For any value of y (including NaN),
565 	 * if x is 1.0, 1.0 shall be returned.
566 	 */
567 	if (powf(1.0, z) != 1.0)
568 		atf_tc_fail_nonfatal("powf(1.0, NaN) != 1.0");
569 
570 	for (i = 0; i < __arraycount(y); i++) {
571 
572 		if (powf(1.0, y[i]) != 1.0)
573 			atf_tc_fail_nonfatal("powf(1.0, %0.01f) != 1.0", y[i]);
574 	}
575 #endif
576 }
577 
578 ATF_TC(powf_zero_x);
579 ATF_TC_HEAD(powf_zero_x, tc)
580 {
581 	atf_tc_set_md_var(tc, "descr", "Test powf(+-0.0, y) == +-0.0 || HUGE");
582 }
583 
584 ATF_TC_BODY(powf_zero_x, tc)
585 {
586 #ifndef __vax__
587 	float z;
588 
589 	/*
590 	 * If x is +0.0 or -0.0, y > 0, and y
591 	 * is an odd integer, x is returned.
592 	 */
593 	z = powf(+0.0, 3.0);
594 
595 	if (fabsf(z) > 0.0 || signbit(z) != 0)
596 		atf_tc_fail_nonfatal("powf(+0.0, 3.0) != +0.0");
597 
598 	z = powf(-0.0, 3.0);
599 
600 	if (fabsf(z) > 0.0 || signbit(z) == 0)
601 		atf_tc_fail_nonfatal("powf(-0.0, 3.0) != -0.0");
602 
603 	/*
604 	 * If y > 0 and not an odd integer,
605 	 * if x is +0.0 or -0.0, +0.0 is returned.
606 	 */
607 	z = powf(+0.0, 4.0);
608 
609 	if (fabsf(z) > 0.0 || signbit(z) != 0)
610 		atf_tc_fail_nonfatal("powf(+0.0, 4.0) != +0.0");
611 
612 	z = powf(-0.0, 4.0);
613 
614 	if (fabsf(z) > 0.0 || signbit(z) != 0)
615 		atf_tc_fail_nonfatal("powf(-0.0, 4.0) != +0.0");
616 
617 	/*
618 	 * If y < 0 and x is +0.0 or -0.0, either +-HUGE_VAL,
619 	 * +-HUGE_VALF, or +-HUGE_VALL shall be returned.
620 	 */
621 	z = powf(+0.0, -4.0);
622 
623 	if (z != HUGE_VALF) {
624 		atf_tc_expect_fail("PR port-amd64/45391");
625 		atf_tc_fail_nonfatal("powf(+0.0, -4.0) != HUGE_VALF");
626 	}
627 
628 	z = powf(-0.0, -4.0);
629 
630 	if (z != HUGE_VALF) {
631 		atf_tc_expect_fail("PR port-amd64/45391");
632 		atf_tc_fail_nonfatal("powf(-0.0, -4.0) != HUGE_VALF");
633 	}
634 
635 	z = powf(+0.0, -5.0);
636 
637 	if (z != HUGE_VALF) {
638 		atf_tc_expect_fail("PR port-amd64/45391");
639 		atf_tc_fail_nonfatal("powf(+0.0, -5.0) != HUGE_VALF");
640 	}
641 
642 	z = powf(-0.0, -5.0);
643 
644 	if (z != -HUGE_VALF)
645 		atf_tc_fail_nonfatal("powf(-0.0, -5.0) != -HUGE_VALF");
646 #endif
647 }
648 
649 ATF_TC(powf_zero_y);
650 ATF_TC_HEAD(powf_zero_y, tc)
651 {
652 	atf_tc_set_md_var(tc, "descr", "Test powf(x, +-0.0) == 1.0");
653 }
654 
655 ATF_TC_BODY(powf_zero_y, tc)
656 {
657 #ifndef __vax__
658 	const float x[] =  { 0.1, -3.0, 77.0, 99.99, 101.0000001 };
659 	const float z = 0.0L / 0.0L;
660 	size_t i;
661 
662 	/*
663 	 * For any value of x (including NaN),
664 	 * if y is +0.0 or -0.0, 1.0 is returned.
665 	 */
666 	if (powf(z, +0.0) != 1.0)
667 		atf_tc_fail_nonfatal("powf(NaN, +0.0) != 1.0");
668 
669 	if (powf(z, -0.0) != 1.0)
670 		atf_tc_fail_nonfatal("powf(NaN, -0.0) != 1.0");
671 
672 	for (i = 0; i < __arraycount(x); i++) {
673 
674 		if (powf(x[i], +0.0) != 1.0)
675 			atf_tc_fail_nonfatal("powf(%0.01f, +0.0) != 1.0",x[i]);
676 
677 		if (powf(x[i], -0.0) != 1.0)
678 			atf_tc_fail_nonfatal("powf(%0.01f, -0.0) != 1.0",x[i]);
679 	}
680 #endif
681 }
682 
683 ATF_TP_ADD_TCS(tp)
684 {
685 
686 	ATF_TP_ADD_TC(tp, pow_nan_x);
687 	ATF_TP_ADD_TC(tp, pow_nan_y);
688 	ATF_TP_ADD_TC(tp, pow_inf_neg_x);
689 	ATF_TP_ADD_TC(tp, pow_inf_neg_y);
690 	ATF_TP_ADD_TC(tp, pow_inf_pos_x);
691 	ATF_TP_ADD_TC(tp, pow_inf_pos_y);
692 	ATF_TP_ADD_TC(tp, pow_one_neg_x);
693 	ATF_TP_ADD_TC(tp, pow_one_pos_x);
694 	ATF_TP_ADD_TC(tp, pow_zero_x);
695 	ATF_TP_ADD_TC(tp, pow_zero_y);
696 
697 	ATF_TP_ADD_TC(tp, powf_nan_x);
698 	ATF_TP_ADD_TC(tp, powf_nan_y);
699 	ATF_TP_ADD_TC(tp, powf_inf_neg_x);
700 	ATF_TP_ADD_TC(tp, powf_inf_neg_y);
701 	ATF_TP_ADD_TC(tp, powf_inf_pos_x);
702 	ATF_TP_ADD_TC(tp, powf_inf_pos_y);
703 	ATF_TP_ADD_TC(tp, powf_one_neg_x);
704 	ATF_TP_ADD_TC(tp, powf_one_pos_x);
705 	ATF_TP_ADD_TC(tp, powf_zero_x);
706 	ATF_TP_ADD_TC(tp, powf_zero_y);
707 
708 	return atf_no_error();
709 }
710