fork download
  1. #include <stdio.h>
  2.  
  3. unsigned int binaryLength(unsigned int n)
  4. {
  5. unsigned int i = 0;
  6. while (n >>= 1)
  7. {
  8. ++i;
  9. }
  10.  
  11. return i;
  12. }
  13.  
  14. int main(void) {
  15. printf("%u\n", binaryLength(0xF1));
  16. printf("%u\n", binaryLength(~0));
  17. // your code goes here
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
7
31