|
@ -1,6 +1,7 @@ |
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
#include <math.h> |
|
|
#include <math.h> |
|
|
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
#include "conversionOfNumbers.h" |
|
|
#include "conversionOfNumbers.h" |
|
|
|
|
|
|
|
@ -42,12 +43,12 @@ char* convertIntToBinaryStr(int input){ |
|
|
|
|
|
|
|
|
unsigned int convertBinaryStrToInt(char* input){ |
|
|
unsigned int convertBinaryStrToInt(char* input){ |
|
|
unsigned int result = 0; |
|
|
unsigned int result = 0; |
|
|
int x = 0; |
|
|
|
|
|
while(input[x] != '\0'){ |
|
|
|
|
|
if(input[x] == '1'){ |
|
|
|
|
|
result += 1 * pow(2, x); |
|
|
|
|
|
} |
|
|
|
|
|
x++; |
|
|
|
|
|
|
|
|
int index = strlen(input) - 1; |
|
|
|
|
|
int exponent = 0; |
|
|
|
|
|
while(index >= 0){ |
|
|
|
|
|
if(input[index] == '1') result += 1 * pow(2, exponent); |
|
|
|
|
|
index--; |
|
|
|
|
|
exponent++; |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|