/* sqrttestgen.c */ /* Written 7/22/2022 by Cedar Turek This program creates test vectors for mantissa component of an IEEE floating point square root. */ /* #includes */ #include #include #include /* Constants */ #define ENTRIES 17 #define BIGENT 1000 #define RANDOM_VECS 500 /* Prototypes */ void output(FILE *fptr, int aExp, double aFrac, int rExp, double rFrac); void printhex(FILE *fptr, double x); double random_input(void); /* Main */ void main(void) { FILE *fptr; double aFrac, rFrac; int aExp, rExp; double mans[ENTRIES] = {1, 1849.0/1024, 1.25, 1.125, 1.0625, 1.75, 1.875, 1.99999, 1.1, 1.5, 1.01, 1.001, 1.0001, 2/1.1, 2/1.5, 2/1.25, 2/1.125}; double bigtest[BIGENT]; double exps[ENTRIES] = {0, 0, 2, 3, 4, 5, 6, 7, 8, 1, 10, 11, 12, 13, 14, 15, 16}; int i; int bias = 1023; if ((fptr = fopen("sqrttestvectors","w")) == NULL) { fprintf(stderr, "Couldn't write sqrttestvectors file\n"); exit(1); } // Small Test // for (i=0; i2) m /= 2; for (i=0; i<52; i+=4) { m = m - floor(m); m = m * 16; val = (int)(m)%16; fprintf(fptr, "%x", val); } } double random_input(void) { return 1.0 + ((rand() % 32768)/32767.0); }