diff --git a/src/conversionOfNumbers/conversionOfNumbers.c b/src/conversionOfNumbers/conversionOfNumbers.c index fdaf2e8..86af510 100644 --- a/src/conversionOfNumbers/conversionOfNumbers.c +++ b/src/conversionOfNumbers/conversionOfNumbers.c @@ -5,11 +5,15 @@ #include "conversionOfNumbers.h" int binaryStrLen(int input){ - int length; + int length = 0; if (input == 0) return 1; + if (input < 0){ + input *= -1; + length += 1; + } for (int x = 0; x <= input; x++){ if(pow(2,x) >= input + 1){ - length = x; + length += x; break; } }