In most cases, the length of the operands will not be force 2. I think this is a rare case. Most of the time, there will be different lengths of the operands. But this will not be a problem for the altar of Karatsuba.
In fact, I do not see any problem here. This overhead (odd length) is so light and certainly not big. The problem of different lengths - suppose that X = 1234 and Y = 45
So, a = 12, b = 34, c = 0, d = 45 So, after that X * Y = 10 ^ 4 * ac + 10 ^ 2 (ad + bc) + bd
ac = 0; bd = 34 * 45; ad + bc = (a + b) * (c + d) - ac - bd = 540;
And if we assume that we could easily multiply two-digit numbers - you could get the answer = 55530. The same as just multiply 1234 * 45 in any calculator :) So, I do not see a memory problem with different lengths of numbers.
source share