mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-09 21:47:07 +08:00
Update karatsuba_algorithm_for_fast_multiplication.cpp
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user