-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBigInteger.h
More file actions
64 lines (59 loc) · 2.12 KB
/
Copy pathBigInteger.h
File metadata and controls
64 lines (59 loc) · 2.12 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
#ifndef BIGINTEGER_H
#define BIGINTEGER_H
#define _CRT_SECURE_NO_WARNINGS
#include<vector>
#include<stack>
#include<string>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<iosfwd>
#include<cmath>
#include<cstdlib>
#include<iomanip>
using namespace std;
class BigInteger{
private:
static const int base = 10000;//equal to 10^_bit
static const int width = 4;//compress bits£¬_bit
vector<int> s;
bool sign;//signal bit,>=0 is true(positive); <0 is false(negative)
void reform();
public:
BigInteger(const BigInteger& b);
BigInteger();
BigInteger(const string& str);
BigInteger(const char* str);
BigInteger(const int& num);
BigInteger(const long long& num);
~BigInteger() = default;
BigInteger& operator=(long long num);
BigInteger& operator=(const char* str);
BigInteger& operator=(const string& str);
BigInteger operator=(const int& num);
friend ostream& operator<<(ostream& out, const BigInteger& x);
friend istream& operator>>(istream& in, BigInteger& x);
friend BigInteger operator+(const BigInteger& lhs, const BigInteger& rhs);
BigInteger & operator+=(const BigInteger& rhs);
BigInteger& operator-=(const BigInteger& rhs);
BigInteger& operator++();
BigInteger& operator--();
BigInteger operator++(int);
BigInteger operator--(int);
BigInteger& operator*=(const BigInteger& rhs);
BigInteger& operator/=(const BigInteger& rhs);
friend BigInteger operator%(const BigInteger& lhs, const BigInteger& rhs);
bool operator<(const BigInteger& b)const;
bool operator>(const BigInteger& b)const;
bool operator<=(const BigInteger& b)const;
bool operator>=(const BigInteger& b)const;
bool operator==(const BigInteger& b)const;
bool operator!=(const BigInteger& b)const;
friend BigInteger operator-(const BigInteger& lhs, const BigInteger& rhs);
friend BigInteger operator*(const BigInteger& lhs, const BigInteger& rhs);
friend BigInteger operator/(const BigInteger& divid, const BigInteger& divis);
BigInteger pow(const BigInteger& num)const;
BigInteger factorial()const;
BigInteger Sqrt()const;
};
#endif