-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbig_integer.h
More file actions
104 lines (78 loc) · 3.96 KB
/
big_integer.h
File metadata and controls
104 lines (78 loc) · 3.96 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
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
104
#ifndef BIG_INTEGER_H
#define BIG_INTEGER_H
#include <iosfwd>
#include <vector>
#include <cstdint>
#include <string_view>
#include "dynamic_storage.h"
struct big_integer {
big_integer();
big_integer(big_integer const& x);
big_integer(int32_t val);
explicit big_integer(std::string_view str);
~big_integer();
big_integer& operator=(big_integer const& rhs);
big_integer& operator+=(big_integer const& rhs);
big_integer& operator-=(big_integer const& rhs);
big_integer& operator*=(big_integer const& rhs);
big_integer& operator/=(big_integer const& rhs);
big_integer& operator%=(big_integer const& rhs);
big_integer& operator&=(big_integer const& rhs);
big_integer& operator|=(big_integer const& rhs);
big_integer& operator^=(big_integer const& rhs);
big_integer& operator<<=(int val);
big_integer& operator>>=(int val);
big_integer operator+() const;
big_integer operator-() const;
big_integer operator~() const;
big_integer& operator++();
big_integer operator++(int);
big_integer& operator--();
big_integer operator--(int);
void swap(big_integer& x) noexcept;
friend big_integer operator+(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator-(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator*(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator/(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator%(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator&(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator|(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator^(big_integer const& lhs, big_integer const& rhs);
friend big_integer operator<<(big_integer const& lhs, int val);
friend big_integer operator>>(big_integer const& lhs, int val);
friend bool operator==(big_integer const& lhs, big_integer const& rhs);
friend bool operator!=(big_integer const& lhs, big_integer const& rhs);
friend bool operator<(big_integer const& lhs, big_integer const& rhs);
friend bool operator>(big_integer const& lhs, big_integer const& rhs);
friend bool operator<=(big_integer const& lhs, big_integer const& rhs);
friend bool operator>=(big_integer const& lhs, big_integer const& rhs);
friend void swap(big_integer& lhs, big_integer& rhs) noexcept;
friend big_integer abs(big_integer const& x);
friend std::string to_string(big_integer const& x);
private:
struct helper;
typedef dynamic_storage<uint32_t> container_t;
container_t data;
explicit big_integer(container_t const& data);
};
big_integer operator+(big_integer const& lhs, big_integer const& rhs);
big_integer operator-(big_integer const& lhs, big_integer const& rhs);
big_integer operator*(big_integer const& lhs, big_integer const& rhs);
big_integer operator/(big_integer const& lhs, big_integer const& rhs);
big_integer operator%(big_integer const& lhs, big_integer const& rhs);
big_integer operator&(big_integer const& lhs, big_integer const& rhs);
big_integer operator|(big_integer const& lhs, big_integer const& rhs);
big_integer operator^(big_integer const& lhs, big_integer const& rhs);
big_integer operator<<(big_integer const& lhs, int val);
big_integer operator>>(big_integer const& lhs, int val);
bool operator==(big_integer const& lhs, big_integer const& rhs);
bool operator!=(big_integer const& lhs, big_integer const& rhs);
bool operator<(big_integer const& lhs, big_integer const& rhs);
bool operator>(big_integer const& lhs, big_integer const& rhs);
bool operator<=(big_integer const& lhs, big_integer const& rhs);
bool operator>=(big_integer const& lhs, big_integer const& rhs);
void swap(big_integer& lhs, big_integer& rhs) noexcept;
big_integer abs(big_integer const& x);
std::string to_string(big_integer const& x);
std::ostream& operator<<(std::ostream& os, big_integer const& x);
#endif //BIG_INTEGER_H