h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

intpow_tests.c (469B)


      1 #include "../test.h"
      2 
      3 #define ABS(x) ((x) < 0 ? (-(x)) : (x))
      4 
      5 double intpow(double, uint64_t);
      6 
      7 const double tolerance = 1e-6;
      8 
      9 void run(void) {
     10 	char str[STRLENMAX];
     11 	double b, r, c;
     12 	uint64_t e;
     13 
     14 	fgets(str, STRLENMAX, stdin);
     15 	b = atof(str);
     16 	fgets(str, STRLENMAX, stdin);
     17 	e = atoll(str);
     18 	fgets(str, STRLENMAX, stdin);
     19 	r = atof(str);
     20 
     21 	c = intpow(b, e);
     22 	if (ABS(r - c) > tolerance)
     23 		printf("Error! Expected %lf but got %lf\n", r, c);
     24 	else
     25 		printf("Ok\n");
     26 }