-
Notifications
You must be signed in to change notification settings - Fork 0
/
LN.h
85 lines (45 loc) · 1.39 KB
/
LN.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
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
#include <cstdint>
#include <iostream>
class LN {
public:
LN(long long = 0);
LN(const LN &);
LN(LN &&) noexcept;
explicit LN(std::string_view);
explicit LN(const char *);
LN(int i);
~LN();
LN &operator=(const LN &);
LN &operator=(LN &&) noexcept;
LN operator+(const LN &) const;
LN operator-(const LN &) const;
LN operator*(const LN &) const;
LN operator/(const LN &) const;
LN operator%(const LN &) const;
LN operator~() const;
LN operator-() const;
LN &operator+=(const LN &);
LN &operator-=(const LN &);
LN &operator*=(const LN &);
LN &operator/=(const LN &);
LN &operator%=(const LN &);
LN operator<(const LN &) const;
LN operator<=(const LN &) const;
LN operator>(const LN &) const;
LN operator>=(const LN &) const;
LN operator==(const LN &) const;
LN operator!=(const LN &) const;
explicit operator long long() const;
explicit operator bool() const;
explicit operator std::string() const;
private:
uint32_t *digits_ = nullptr;
bool isNaN_ = false;
int sign_ = 1;
size_t len_ = 0;
void shift_for_one_sign(uint32_t x);
void delete_zero();
[[nodiscard]] int compareDigits(const LN &x) const;
void add(const LN &);
void sub(const LN &);
};