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.

20 lines
427 B

25 years ago
  1. #include "test_I.h"
  2. int test_I_power2p (int iterations)
  3. {
  4. int error = 0;
  5. int i;
  6. // Check powers of 2.
  7. for (i = iterations; i > 0; i--) {
  8. uintL n = random32() % 1024;
  9. cl_I a = ash(1,n);
  10. ASSERT1(power2p(a) == n+1, n);
  11. }
  12. // Check against logcount.
  13. for (i = iterations; i > 0; i--) {
  14. cl_I a = testrandom_I();
  15. if (a > 0)
  16. ASSERT1(power2p(a) == (logcount(a) == 1 ? integer_length(a) : 0), a);
  17. }
  18. return error;
  19. }