Browse Source

implemented prototype function to convert binary strings of 1s into decimal

remotes/origin/conversionOfNumbers
Laurin 11 months ago
parent
commit
a7218c6a73
  1. 12
      src/conversionOfNumbers/conversionOfNumbers.c

12
src/conversionOfNumbers/conversionOfNumbers.c

@ -37,4 +37,16 @@ char* convertIntToBinaryStr(int input){
length--; length--;
}while(input != 0); }while(input != 0);
return result; return result;
}
unsigned int convertBinaryStrToInt(char* input){
unsigned int result = 0;
int x = 0;
while(input[x] != '\0'){
if(input[x] == '1'){
result += 1 * pow(2, x);
}
x++;
}
return result;
} }
Loading…
Cancel
Save