コード例 #1
0
ファイル: BigInt.cpp プロジェクト: Noligz/CppPractice
BigInt& BigInt::operator*(const BigInt& x) const
{
	BigInt* result = new BigInt();
	BigInt a = Abs();
	BigInt b = x.Abs();

	for(long long i = 0; i < MAXBIT - 1; i++)
	{
		if(x.GetElement(i) == 0)
			continue;
		for(long long j = 0; j < MAXBIT - 1; j++)
		{
			if(a.GetElement(j) == 0)
				continue;
			result->SetElenemt(i + j, result->GetElement(i + j) + a.GetElement(j) * x.GetElement(i));
		}

		result->Refine();
	}

	if(isNegtive() == x.isNegtive())
		result->SetElenemt(MAXBIT - 1, 0);
	else
		result->SetElenemt(MAXBIT - 1, JINZHI - 1);

	return *result;
}
コード例 #2
0
ファイル: BigInt.cpp プロジェクト: Noligz/CppPractice
BigInt::BigInt(const BigInt& x)
{
	m_element = new unsigned long long[MAXBIT];
	m_isRefined = false;
	for(long long i = 0; i < MAXBIT; i++)
		m_element[i] = x.GetElement(i);
	Refine();
}