-
Notifications
You must be signed in to change notification settings - Fork 0
/
Num.h
37 lines (33 loc) · 1.08 KB
/
Num.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
#ifndef NUM_H
#define NUM_H
#include<string>
#include<vector>
using namespace std;
class Num
{
private:
vector<char> _num;
bool _minus;
void carry(void);
void decomp(void);
inline void setMinus(void);
public:
Num(vector<char>& num,bool isMinus=false): _num(num),_minus(isMinus){setMinus();carry();decomp();}
Num(vector<int>& num,bool isMinus=false): _minus(isMinus){_num.insert(_num.begin(),num.begin(),num.end());setMinus();carry();decomp();}
Num(){_minus=false;}
inline int length(void) const;
inline char getBit(char) const;
inline void inverse(void){_minus=!_minus;}
inline bool isMinus(void)const {return _minus;}
Num operator+(const Num&) const;
Num operator-(const Num&) const;
Num operator*(const Num&) const;
inline Num& operator++();
inline Num operator++(int);
inline Num& operator--();
inline Num operator--(int);
inline const vector<char> getnum(void) const;
friend istream& operator>>(istream& , Num&);
friend ostream& operator<<(ostream& , Num&);
};
#endif // NUM_H