-
Notifications
You must be signed in to change notification settings - Fork 0
/
big_integer.h
executable file
·67 lines (51 loc) · 2.12 KB
/
big_integer.h
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
//file:big_integer.h
//big_integer class implementation file
#ifndef BIG_INTEGER_H
#define BIG_INTEGER_H
#include <vector>
#include <string>
using namespace std;
class big_integer {
public:
//constructor
big_integer(string);
//creates a big_integer by filling the 'digits' vector and assiging the 'negative'
//value. Starts with the number represented as a string.
big_integer();
//default constructor
//creates empty big_integer
big_integer add (big_integer other);
//performs an addition between the current big_integer and the other one.
//returns a big_integer.
big_integer subtract (big_integer other);
//performs a subtraction between the current big_integer and the other one.
//returns a big_integer.
big_integer multiply (big_integer other);
//performs a multiplication between the current big_integer and the other one.
//returns a big_integer.
big_integer div(big_integer other);
//performs integer division between the current big_integer and the other one.
//returns a big_integer.
big_integer mod(big_integer other);
//performs integer modulo between the current big_integer and the other one.
//returns a big_integer.
bool equals(big_integer other);
//returns True iff the current big_integer equals the other big_integer.
big_integer absolute();
//returns the absolute version of the current big_integer
bool bigger_than(big_integer other);
//returns True if the current big_integer bigger the other big_integer
big_integer sub(int pos = 0, int size = 0);
//returns a big integer from the current integer starting from the pos digit and size
//count of digits
string output();
//produces a string output from the 'digits' and 'negative' features.
private:
bool negative; //True if the integer is negative.
vector <int> digits; //A vector that stores the big integer.
void normalize();
//deletes leading zoros from the current big_integer
void discard(int pos = 0, int size = 0);
//discards size count of digits from the current big_integer
};//end big_integer class
#endif