您的位置:首页 > 编程语言 > C语言/C++

c++ 大数运算测试代码

2007-08-24 16:17 295 查看
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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: