Browse Source

refactoring: moved if statement for input 0 to top

remotes/origin/conversionOfNumbers
Laurin 11 months ago
parent
commit
69d57301a1
  1. 7
      src/conversionOfNumbers/conversionOfNumbers.c

7
src/conversionOfNumbers/conversionOfNumbers.c

@ -6,16 +6,13 @@
int binaryStrLen(int input){ int binaryStrLen(int input){
int length; int length;
if(input > 0){
for(int x = 0; x <= input; x++){
if (input == 0) return 1;
for (int x = 0; x <= input; x++){
if(pow(2,x) >= input + 1){ if(pow(2,x) >= input + 1){
length = x; length = x;
break; break;
} }
} }
}else if(input == 0){
length = 1;
}
return length; return length;
} }

Loading…
Cancel
Save