本文整理汇总了C++中BigNumber::IsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ BigNumber::IsInt方法的具体用法?C++ BigNumber::IsInt怎么用?C++ BigNumber::IsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigNumber
的用法示例。
在下文中一共展示了BigNumber::IsInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Multiply
void BigNumber::Multiply(const BigNumber& aX, const BigNumber& aY, int aPrecision)
{
SetIsInteger(aX.IsInt() && aY.IsInt());
if (aPrecision<aX.GetPrecision()) aPrecision=aX.GetPrecision();
if (aPrecision<aY.GetPrecision()) aPrecision=aY.GetPrecision();
iNumber->ChangePrecision(bits_to_digits(aPrecision,10));
// if (iNumber == aX.iNumber || iNumber == aY.iNumber)
{
ANumber a1(*aX.iNumber);
ANumber a2(*aY.iNumber);
:: Multiply(*iNumber,a1,a2);
}
/*TODO I don't like that multiply is destructive, but alas... x=pi;x*0.5 demonstrates this. FIXME
else
{
:: Multiply(*iNumber,*aX.iNumber,*aY.iNumber);
}
*/
}
示例2: Negate
void BigNumber::Negate(const BigNumber& aX)
{
if (aX.iNumber != iNumber)
{
iNumber->CopyFrom(*aX.iNumber);
}
iNumber->Negate();
SetIsInteger(aX.IsInt());
}
示例3: Divide
void BigNumber::Divide(const BigNumber& aX, const BigNumber& aY, int aPrecision)
{
/*
iPrecision = DividePrecision(aX, aY, aPrecision);
int digitPrecision = bits_to_digits(iPrecision,10);
iNumber->iPrecision = digitPrecision;
*/
/* */
if (aPrecision<aX.GetPrecision()) aPrecision=aX.GetPrecision();
if (aPrecision<aY.GetPrecision()) aPrecision=aY.GetPrecision();
int digitPrecision = bits_to_digits(aPrecision,10);
iPrecision = aPrecision;
iNumber->iPrecision = digitPrecision;
/* */
ANumber a1(*aX.iNumber);
// a1.CopyFrom(*aX.iNumber);
ANumber a2(*aY.iNumber);
// a2.CopyFrom(*aY.iNumber);
ANumber remainder(digitPrecision);
if (a2.IsZero())
throw LispErrInvalidArg();
if (aX.IsInt() && aY.IsInt())
{
if (a1.iExp != 0 || a2.iExp != 0)
throw LispErrNotInteger();
SetIsInteger(true);
::IntegerDivide(*iNumber, remainder, a1, a2);
}
else
{
SetIsInteger(false);
::Divide(*iNumber,remainder,a1,a2);
}
}
示例4: Add
void BigNumber::Add(const BigNumber& aX, const BigNumber& aY, int aPrecision)
{
SetIsInteger(aX.IsInt() && aY.IsInt());
if (aPrecision<aX.GetPrecision()) aPrecision=aX.GetPrecision();
if (aPrecision<aY.GetPrecision()) aPrecision=aY.GetPrecision();
if (iNumber != aX.iNumber && iNumber != aY.iNumber &&
aX.iNumber->iExp == aY.iNumber->iExp && aX.iNumber->iTensExp == aY.iNumber->iTensExp)
{
::Add(*iNumber, *aX.iNumber, *aY.iNumber);
}
else
{
ANumber a1(*aX.iNumber );
ANumber a2(*aY.iNumber );
::Add(*iNumber, a1, a2);
}
iNumber->SetPrecision(aPrecision);
/* */
}
示例5: SetTo
void BigNumber::SetTo(const BigNumber& aOther)
{
iPrecision = aOther.GetPrecision();
if (!iNumber)
{
iNumber = new ANumber(*aOther.iNumber);
}
else
{
iNumber->CopyFrom(*aOther.iNumber);
}
SetIsInteger(aOther.IsInt());
}
示例6: iReferenceCount
BigNumber::BigNumber(const BigNumber& aOther)
: iReferenceCount(),iPrecision(aOther.GetPrecision()),iType(KInt),iNumber(nullptr)
{
iNumber = new ANumber(*aOther.iNumber);
SetIsInteger(aOther.IsInt());
}