1

I am trying to implement level-3 Karatsuba multiplication for multiplication of two 256-bits operands. I want to use radix-2^32 representation of my operands, therefore I have implemented schoolbook multiplication of two 32-bit operands so far which I intend to use inside my Karatsuba multiplication function. As long as I know, I can divide my operands as follow:

level-1 :AB = A0B0 + ((A0 + A1)(B0 + B1) - A0B0 - A1B1)(x^(m/2)) + A1B1(x^m)
level-2 : A0B0 = A00B00 + ((A00 + A01)(B00 + B01) - A00B00 - A01B01)(x^m/2)) + A01B01(x^m)
level-3 : A00B00 = A000B000 + ((A000 + A001)(B000 + B001) - A000B000 - A001B001)(x^(m/2)) + A001B001(x^m)

As you can see here, A and B have 256-bits while A000 and B000 has 32-bits which properly fit into my unit32_t data type. As I mentioned before I have already implemented schoolbook multiplication for two 32-bits operands and it works fine. Here is my problem, in level-3, when I add two 32-bits operands (A000 + A0001) and (B000 + B0001), I've got 33-bits result because of carry. Therefore, I should multiply two 33-bits operands and get 66-bits result which is not intended in my case! So, how can I implement this algorithm using only uint32_t data type representation?

A23149577
  • 2,045
  • 2
  • 40
  • 74
  • 1
    Your carry says it: if the array elements that represent the big number are 32-bit, you must work with 64-bit intermediate computations. If you can only use 32-bit max, then the array should be 16-bit. – Weather Vane Nov 17 '15 at 18:47

0 Answers0