Click here to Skip to main content
15,891,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Recently i am learning a algorithm karatsuba which is the fasted multiplication algorithm..It was fine when x = 1234 , y = 4658 ,because the number is even digits number. So i can easily separate two portion of x and y
x= 1234 , so a = 12 , b = 34
y= 4658 , so c = 46 , d = 58

. But if x = 123 then how can i separate two portion ?
Posted

1 solution

a = 1, b = 23
Or am I missing something?
See https://en.wikipedia.org/wiki/Karatsuba_algorithm[^] and follow the example. In your case, the factor is 100, not 1000 as in the example.
Regards
Andi
 
Share this answer
 
Comments
Devils-ey3 18-Oct-15 17:51pm    
But one confusion. Let consider x = 6 bit number, y = 4 bit number.
The formula is x.y = 10^n * AC + 10^(n/2) (AD+BC) + BD
where A = first 3 bits of x and b = last 3 bits of x,
C = first 2 bit of y and D = last 2 bit of y.
So what will be the value of n ?
Andreas Gieriet 19-Oct-15 16:01pm    
To my understanding, both numbers have to be split with respect to the same base B. The algorithm does not work if you split the numbers differently. E.g. if your base is 2 and you split to 3 bits, your x is 3 + 3 bits, y is 1 + 3 bits.
Regards
Andi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900