LIPH's C++ Codes
big_integer.h
Go to the documentation of this file.
1#ifndef LIPH_NUMERIC_BIG_INTEGER_H_
2#define LIPH_NUMERIC_BIG_INTEGER_H_
3
4#include <cstdint>
5#include <string>
6#include <vector>
7
8namespace liph {
9
11public:
12 using byte = unsigned char;
13
14public:
15 big_integer(long long n = 0);
16 explicit big_integer(const std::string& str);
17 big_integer(const big_integer& other);
18 big_integer& operator=(const big_integer& other);
19 big_integer(big_integer&& other);
21
22 int sign() const;
23 bool zero() const;
24 std::string string() const;
25
26 bool operator==(const big_integer& other) const;
27 bool operator!=(const big_integer& other) const;
28 bool operator<(const big_integer& other) const;
29 bool operator<=(const big_integer& other) const;
30 bool operator>(const big_integer& other) const;
31 bool operator>=(const big_integer& other) const;
32
33 big_integer operator+(const big_integer& other) const;
34 big_integer operator-(const big_integer& other) const;
35 big_integer operator*(const big_integer& other) const;
36 big_integer operator/(const big_integer& other) const;
37 big_integer operator-() const;
38 big_integer abs() const;
39
40 static big_integer rand(int max_size = 128);
41
42private:
43 int sign_{0};
44 std::vector<byte> data_;
45};
46
47} // namespace liph
48
49inline liph::big_integer operator""_bi(const char *str, std::size_t size) {
50 liph::big_integer bi(std::string(str, size));
51 return bi;
52}
53
54#endif // LIPH_NUMERIC_BIG_INTEGER_H_
Definition: big_integer.h:10
bool zero() const
Definition: big_integer.cpp:416
big_integer abs() const
Definition: big_integer.cpp:408
bool operator>(const big_integer &other) const
Definition: big_integer.cpp:313
bool operator<=(const big_integer &other) const
Definition: big_integer.cpp:320
big_integer & operator=(const big_integer &other)
Definition: big_integer.cpp:249
bool operator==(const big_integer &other) const
Definition: big_integer.cpp:302
unsigned char byte
Definition: big_integer.h:12
bool operator<(const big_integer &other) const
Definition: big_integer.cpp:306
big_integer operator+(const big_integer &other) const
Definition: big_integer.cpp:334
std::string string() const
Definition: big_integer.cpp:290
int sign() const
Definition: big_integer.cpp:418
big_integer operator/(const big_integer &other) const
Definition: big_integer.cpp:381
static big_integer rand(int max_size=128)
Definition: big_integer.cpp:420
big_integer operator*(const big_integer &other) const
Definition: big_integer.cpp:373
bool operator>=(const big_integer &other) const
Definition: big_integer.cpp:327
big_integer operator-() const
Definition: big_integer.cpp:367
big_integer(long long n=0)
Definition: big_integer.cpp:238
bool operator!=(const big_integer &other) const
Definition: big_integer.cpp:304
Definition: algorithm.h:10