test_big_int.cpp

来自「关于linux环境下的nasm代码的生成和使用」· C++ 代码 · 共 42 行

CPP
42
字号
/* * file: big_int_test.cpp * A small test program for the Big_int class */#include "big_int.hpp"#include <iostream>// Borland (or at least bcc32 ver 5.2) doesn't support the std namespace#if ! ( ( defined(__BORLANDC__) && __BORLANDC__ < 0x550 ) || defined(__WATCOMC__) )using namespace std;#endifint main(){  try {    //           12345678901234567890    Big_int b(5,"8000000000000a00b");    Big_int a(5,"80000000000010230");    Big_int c = a + b;    cout << a << " + " << b << " = " << c << endl;    for( int i=0; i < 2; i++ ) {      c = c + a;      cout << "c = " << c << endl;    }    cout << "c-1 = " << c - Big_int(5,1) << endl;    Big_int d(5, "12345678");    cout << "d = " << d << endl;    cout << "c == d " << (c == d) << endl;    cout << "c > d " << (c > d) << endl;  }  catch( const char * str ) {    cerr << "Caught: " << str << endl;  }  catch( Big_int::Overflow ) {    cerr << "Overflow" << endl;  }  catch( Big_int::Size_mismatch ) {    cerr << "Size mismatch" << endl;  }  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?