lundi 28 février 2022

Bigint array multiply i tried this code and it didn't work with multiply more than two digits numbers

i tried this code and it didn't work with multiply more than two digits numbers


LargeInteger LargeInteger :: operator*(const LargeInteger& L) const{
    `LargeInteger obj;
    LargeInteger R;`
    short int counter = 0;
    int c = 0;
    short int x, y;
    for (int i = 0; i  1)
                {
                    obj.length++;
                    counter--;
                }
                else
                {
                    if (x * y + c >= 10 && j == MaxNumber(L).length - 1)
                    {
                        obj.number[j] = x * y + c;
                        obj.number[j] %= 10;
                        obj.number[j++] = c;
                        obj.length +=2;
                    }
                    else {
                        obj.number[j] = x * y + c;
                        c = obj.number[j] / 10;
                        obj.number[j] %= 10;
                        obj.length++;
                    }
                }
            }
        else counter++;
        counter++;
        R = R + obj; 
    }

    return R;
}

i did plus operator for bigint class and I have make operator for multiply but it's not work with 2 digits multiply can some one help me \this if my code

Aucun commentaire:

Enregistrer un commentaire