-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBigInteger.hpp
103 lines (73 loc) · 3.25 KB
/
BigInteger.hpp
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
#pragma once
#include <string>
using std::istream;
using std::ostream;
using std::string;
typedef unsigned char uc;
typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
class BigInteger
{
private:
uc Sign : 1;
string Num;
string BuildNumStr(ll &);
BigInteger SubtractionHelper(const BigInteger &, const ui &, const ui &) const;
public:
BigInteger();
BigInteger(ll);
BigInteger(const char *);
BigInteger(const string &);
BigInteger(const uc, const string &);
BigInteger(const BigInteger &);
BigInteger(BigInteger &&) noexcept;
bool IsNull() const;
const ui Length() const;
BigInteger Add(const BigInteger &) const;
BigInteger Subtract(const BigInteger &) const;
BigInteger Multiply(const BigInteger &) const;
BigInteger Divide(const BigInteger &) const;
BigInteger Pow(const BigInteger &) const;
// Getters & Setters
const uc GetSign() const;
void SetSign(const uc);
const string GetNum() const;
void SetNum(const string &);
const uc operator[](const ui &) const;
friend BigInteger operator+(const BigInteger &, const BigInteger &);
friend BigInteger operator+(const BigInteger &, const ll &);
friend BigInteger operator-(const BigInteger &, const BigInteger &);
friend BigInteger operator*(const BigInteger &, const BigInteger &);
friend BigInteger operator*(const BigInteger &, const ll &);
friend BigInteger operator/(const BigInteger &, const BigInteger &);
friend BigInteger operator^(const BigInteger &, const BigInteger &);
BigInteger operator++(int temp); // postfix increment
BigInteger &operator++(); // prefix increment
BigInteger operator--(int temp); // postfix decrement
BigInteger &operator--(); // prefix decrement
friend bool operator==(const BigInteger &, const BigInteger &);
friend bool operator==(const BigInteger &, const char *);
friend bool operator!=(const BigInteger &, const BigInteger &);
friend bool operator!=(const BigInteger &, const char *);
friend bool operator<(const BigInteger &, const BigInteger &);
friend bool operator<(const BigInteger &, const string &);
friend bool operator>(const BigInteger &, const BigInteger &);
friend bool operator>(const BigInteger &, const string &);
friend bool operator<=(const BigInteger &, const BigInteger &);
friend bool operator>=(const BigInteger &, const BigInteger &);
BigInteger &operator=(const BigInteger &);
BigInteger &operator=(BigInteger &&) noexcept;
friend BigInteger &operator+=(BigInteger &, const BigInteger &);
friend BigInteger &operator+=(BigInteger &, const ll &);
friend BigInteger &operator-=(BigInteger &, const BigInteger &);
friend BigInteger &operator-=(BigInteger &, const ll &);
friend BigInteger &operator*=(BigInteger &, const BigInteger &);
friend BigInteger &operator*=(BigInteger &, const ll &);
friend BigInteger &operator/=(BigInteger &, const BigInteger &);
friend BigInteger &operator/=(BigInteger &, const ll &);
friend BigInteger &operator^=(BigInteger &, const BigInteger &);
// OutStream & InStream
friend ostream &operator<<(ostream &, const BigInteger &);
friend istream &operator>>(istream &, BigInteger &);
};