Thanks for the suggestion of using hex, and a much quicker way to split each long number. Also, I should be able to use printing a ull without a debugger (esp. since I don't have a debugger). This is what I have now, the multiply function uses bit shifts created from psudeocode on wiki, wild guess that a working algorithm is much more complicated than this:
Code:
long karatsubaAlg(int x, int y) {
int x1 = x >> 16;
int x2 = x & 0xFFFF;
int y1 = y >> 16;
int y2 = y & 0xFFFF;
long a, b, c, k;
a = multiply(x1, y1);
b = multiply(x2, y2);
c = multiply(x1+x2, y1+y2);
k = c - a - b;
return multiply(a, 100 + multiply(k, 10)+b);
}
This does not produce the correct result, e.g.
Code:
0x11112222L * 0x1111EAL = 17217014364469104 //MS Calc gives: 12355012F7514
I read an article on wikipedia - the place that explains a hell of alot, not very well - and find it annoying that there is a lack of sites that explain it using terms "normal people" can understand. I only just discovered bit shifts yesterday and am used to biting off more than I can chew (it worked with windows programming ). I was thinking of implementing other algorithms like this one but they will all be ridiculously hard to understand - they were probably written by the same people who wrote the maths pages on wiki ha.