Update karatsuba_algorithm_for_fast_multiplication.cpp

This commit is contained in:
Swastika Gupta
2021-07-31 16:17:38 +05:30
committed by GitHub
parent 2e1ef74f31
commit 4e073f5b9f

View File

@@ -59,9 +59,10 @@ std::string addStrings( std::string first, std::string second )
int64_t secondBit = second.at(i) - '0';
int64_t sum = (firstBit ^ secondBit ^ carry)+'0'; // sum of 3 bits
sum = std::to_string(sum);
sum += result;
result = sum;
std::string temp;
temp = std::to_string(sum);
temp += result;
result = temp;
carry = (firstBit&secondBit) | (secondBit&carry) | (firstBit&carry); // sum of 3 bits
}