-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
121 lines (82 loc) · 2.32 KB
/
main.cpp
File metadata and controls
121 lines (82 loc) · 2.32 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "BigInt.h"
#include "time.h"
#include <bitset>
int main () {
clock_t ticks1, ticks2;
cout<<"\n\nTest Suite for BigInt :\n"<<endl;
cout<<"\nDo you want to print the results? (coded in base 2147483648) : \n(Y = YES / N = NO)\n----> ";
char in;
bool print;
cin >> in ;
cout<<"\n";
if(in == 'Y')
print = true;
else
print = false;
cout<<"- division"<<endl;
BigInt a ("21742178472138971249812481241921247129417284184124719417471");
BigInt b (5);
cout << "value a: "<< a << endl;
cout << "value b: "<< b << endl;
ticks1=clock();
a/=b;
ticks2=clock();
cout << "operation time (ms) : " << ticks2-ticks1<<endl;
if(print)
cout << "result : " << a <<endl;
cout<<"\n- multiplication"<<endl;
BigInt z1 ("-483249324");
BigInt z2 ("321321312331");
cout << "value a: "<< z1 << endl;
cout << "value b: "<< z2 << endl;
ticks1=clock();
z1-=z2;
ticks2=clock();
cout << "operation time (ms) : " << ticks2-ticks1<<endl;
if(print)
cout << "result : " << z1 <<endl;
cout<<"\n- pow"<<endl;
BigInt x ("4214432433");
BigInt y (5424);
cout << "value a: "<< x << endl;
cout << "value b: "<< y << endl;
ticks1=clock();
x=pow(x,y);
ticks2=clock();
cout << "operation time (ms) : " << ticks2-ticks1<<endl;
if(print)
//cout << "result : " << x <<endl;
cout<<"\n- sum"<<endl;
BigInt s1 ("58932785918745932751238957382915718957238957385473895718325789257328141");
BigInt s2 ("72314821738921738217382137218937812937981273821372918372189378921372819371289371289378127839");
cout << "value a: "<< s1 << endl;
cout << "value b: "<< s2 << endl;
ticks1=clock();
s1+=s2;
ticks2=clock();
cout << "operation time (ms) : " << ticks2-ticks1<<endl;
if(print)
cout << "result : " << s1 <<endl;
cout<<"\n- subtract"<<endl;
BigInt p1 ("5832798327892374892314");
BigInt p2 ("324671264172864127846172");
cout << "value a: "<< p1 << endl;
cout << "value b: "<< p2 << endl;
ticks1=clock();
p1-=p2;
ticks2=clock();
cout << "operation time (ms) : " << ticks2-ticks1<<endl;
if(print)
cout << "result : " << p1 <<endl;
cout<<"\n- shift"<<endl;
BigInt r1 ("2132132131");
cout << "value a: "<< r1 << endl;
ticks1=clock();
BigInt one (1);
BigInt r2 = r1<<one;
ticks2=clock();
cout << "operation time (ms) : " << ticks2-ticks1<<endl;
if(print)
cout << "result : " << r2 <<endl;
return 0;
}