expose bigint mul,div,mod functions

svn path=/trunk/kdesupport/qca/; revision=703509
This commit is contained in:
Justin Karneges 2007-08-22 17:57:51 +00:00
parent 0046132348
commit 51adb11e2d
2 changed files with 55 additions and 0 deletions

View File

@ -642,6 +642,27 @@ a -= b; // a is now -1000
*/
BigInteger & operator-=(const BigInteger &b);
/**
Multiply in place operator
\param b the amount to multiply by
*/
BigInteger & operator*=(const BigInteger &b);
/**
Divide in place operator
\param b the amount to divide by
*/
BigInteger & operator/=(const BigInteger &b);
/**
Modulo in place operator
\param b the amount to divide by
*/
BigInteger & operator%=(const BigInteger &b);
/**
Output %BigInteger as a byte array, useful for storage or
transmission. The format is a binary integer in sign-extended

View File

@ -846,6 +846,40 @@ BigInteger & BigInteger::operator-=(const BigInteger &i)
return *this;
}
BigInteger & BigInteger::operator*=(const BigInteger &i)
{
d->n *= i.d->n;
return *this;
}
BigInteger & BigInteger::operator/=(const BigInteger &i)
{
try
{
d->n /= i.d->n;
}
catch(std::exception &)
{
fprintf(stderr, "QCA: Botan integer division error\n");
abort();
}
return *this;
}
BigInteger & BigInteger::operator%=(const BigInteger &i)
{
try
{
d->n %= i.d->n;
}
catch(std::exception &)
{
fprintf(stderr, "QCA: Botan integer division error\n");
abort();
}
return *this;
}
BigInteger & BigInteger::operator=(const QString &s)
{
fromString(s);