void multiply(const bigint &A) { bigint temp1; // bigint with value 0 int carry = 0; int shift = 0; bigint temp2; for(int j = size-1; j >= 0; j--) //no member size in bigint { for(int i=size-1; i>=0; i--) { // bigint with value 0 and size: size + A.size int result = (arr->get(i)*A.arr->get(j)+carry); //if(size - shift - (i - size-1) >= 0) temp2.arr->set(size-i, result%10); carry=result/10; } shift++; temp1.add_pos(temp2); } this->assign(temp1); } int main() { a.assign (12345); b.assign (12342357); a.multiply (b); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)