-
Notifications
You must be signed in to change notification settings - Fork 0
/
BigInteger.cpp
44 lines (40 loc) · 1.44 KB
/
BigInteger.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "HyperInt.h"
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
HyperInt bigint1(99000);
HyperInt bigint2(313);
HyperInt bigint3(313);
cout<<left<<setw(30)<<"Test ^ operator:"<<(bigint2^bigint3)<<endl;
// cout<<((bigint2^313)^2)<<endl;
// bigint1 = bigint2;
cin >> bigint3;
cout<<left<<setw(30)<<"Test << operator:" << bigint3<<endl;
cout<<left<<setw(30)<<"Test + and += operator:"<<bigint2+bigint1<< endl;
cout<<left<<setw(30)<<"Test * and *= operator:"<<bigint1*bigint2<< endl;
cout<<"The following outputs are testing the function of comparison operators"<<endl;
HyperInt num1(11111111);
HyperInt num2(11111111);
if(num1==num2)
cout<<num1<<"="<<num2<<endl;
if(num1!=bigint1)
cout<<num1<<"!="<<bigint1<<endl;
if(num1>bigint1)
cout<<num1<<">"<<bigint1<<endl;
if(num1>=num2)
cout<<num1<<">="<<num2<<endl;
if(bigint2<bigint1)
cout<<bigint2<<"<"<<bigint1<<endl;
if(bigint2<=num1)
cout<<bigint2<<"<="<<num1<<endl;
if(bigint2)
cout<<bigint2<<" is not zero"<<endl;
cout<<"Before post-increment,bigint2 was: "<<bigint2;
cout<<". After post-increment in the same line, bigint2 is: "<<bigint2++<<endl;
cout<<"After post-increment in the next line, bigint2 is: "<<bigint2<<endl;
cout<<"Before pre-increment,bigint1 was: "<<bigint1;
cout<<". After pre-increment in the same line, bigint1 is: "<<++bigint1<<endl;
cout<<"After pre-increment in the next line, bigint1 is: "<<bigint1;
return 0;
}