You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
537B

  1. #include "mathops.h"
  2. #ifdef TEST
  3. #include <stdlib.h>
  4. int main(void)
  5. {
  6. unsigned u;
  7. for(u=0; u<65536; u++) {
  8. unsigned s = u*u;
  9. unsigned root = ff_sqrt(s);
  10. unsigned root_m1 = ff_sqrt(s-1);
  11. if (s && root != u) {
  12. fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
  13. return 1;
  14. }
  15. if (u && root_m1 != u - 1) {
  16. fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
  17. return 1;
  18. }
  19. }
  20. return 0;
  21. }
  22. #endif /* TEST */