-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBigInt.h
49 lines (47 loc) · 1.61 KB
/
BigInt.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
/**
* @file BigInt.h
*
* @author <a href="mailto:[email protected]">Amirhossein Hakimnejad</a>
* @date Feb 19, 2018
*/
#ifndef BIGNUMBER_BIGINT_H
#define BIGNUMBER_BIGINT_H
#include "Stack.h"
#include <string>
#include <iomanip>
using std::string;
class BigInt {
friend istream& operator>> (istream &, BigInt &);
friend ostream& operator<< (ostream &, const BigInt &);
private:
Stack<int> bigint;
BigInt neg() const;
void pure();
public:
explicit BigInt(int=10);
BigInt(string);
int getSize() const{return bigint.getSize();}
int getTop() const{return bigint.getTop();}
bool isEmpty() const{return bigint.isEmpty();}
bool isFull() const{return bigint.isFull();}
bool isPos() const{return *this == abs();};
BigInt abs() const;
int &operator [] (int n){return bigint[n];}
int operator [] (int n)const{return bigint[n];}
bool operator == (const BigInt &) const;
bool operator != (const BigInt &) const;
bool operator > (const BigInt &) const;
bool operator <= (const BigInt &r) const{ return !(*this > r); }
bool operator < (const BigInt &r) const{ return r > *this; }
bool operator >= (const BigInt &r) const{ return !(*this < r); }
const BigInt& operator = (const BigInt &);
BigInt operator + (const BigInt &) const;
BigInt operator + (const string) const;
BigInt operator - (const BigInt &) const;
BigInt operator * (BigInt &) const;
BigInt operator / (const BigInt &) const;
BigInt &operator ++ (int);
const BigInt& operator += (const BigInt &r);
const BigInt& operator += (string);
};
#endif //BIGNUMBER_BIGINT_H