c++ 大数运算测试代码

bool Test_BigInt()
{
BigInt a = "12345678901234567896";
BigInt b = "98765432109876543216";
BigInt c = "-12345678901234567896";
BigInt d = "-98765432109876543216";
assert(a > 0);
assert(a >= 0);
assert(c < 0);
assert(c <= 0);
assert(a != c);
assert(a == -c);
BigInt e = a / c;
BigInt f = a % c;
assert(e == -1);
assert(f == 0);
BigInt multi = a * b;
assert(multi == c * d);
BigInt g = 20;
BigInt h = "1000";
BigInt pow = g.power(h);
pow.print();
g = "123";
h = "234";
assert((g ^ h) == (123 ^ 234));
assert((g | h) == (123 | 234));
assert((g & h) == (123 & 234));
return true;
}


浙公网安备 33010602011771号