1#include <stdint.h> 2#include <stdio.h> 3#include "mtest.h" 4 5static struct dd_d t[] = { 6#include "crlibm/pow.h" 7#include "ucb/pow.h" 8#include "sanity/pow.h" 9#include "special/pow.h" 10 11}; 12 13int main(void) 14{ 15 #pragma STDC FENV_ACCESS ON 16 double y; 17 float d; 18 int e, i, err = 0; 19 struct dd_d *p; 20 21 for (i = 0; i < sizeof t/sizeof *t; i++) { 22 p = t + i; 23 24 if (p->r < 0) 25 continue; 26 fesetround(p->r); 27 feclearexcept(FE_ALL_EXCEPT); 28 y = pow(p->x, p->x2); 29 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); 30 31 if (!checkexcept(e, p->e, p->r)) { 32 if (fabs(y) < 0x1p-1022 && (e|INEXACT) == (INEXACT|UNDERFLOW)) 33 printf("X "); 34 else 35 err++; 36 printf("%s:%d: bad fp exception: %s pow(%a,%a)=%a, want %s", 37 p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); 38 printf(" got %s\n", estr(e)); 39 } 40 d = ulperr(y, p->y, p->dy); 41 if (!checkulp(d, p->r)) { 42 printf("%s:%d: %s pow(%a,%a) want %a got %a ulperr %.3f = %a + %a\n", 43 p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy); 44 err++; 45 } 46 } 47 return !!err; 48} 49