-
Notifications
You must be signed in to change notification settings - Fork 0
/
bigint.hpp
50 lines (40 loc) · 1.38 KB
/
bigint.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
#pragma once
#include <compare>
#include <cstdint>
#include <vector>
#include <string>
#include <concepts>
//store in reverse order
struct BigInt {
int sign = 1;
std::vector<uint32_t> value;
BigInt ();
BigInt(BigInt const&) = default;
BigInt (std::integral auto);
BigInt (const char*);
BigInt (const std::string&);
//Assignment
BigInt& operator=(const BigInt&);
// Unary arithmetic operators:
BigInt operator+() const; // unary +
BigInt operator-() const; // unary -
// Arithmetic-assignment operators:
BigInt& operator+=(const BigInt&);
BigInt& operator-=(const BigInt&);
BigInt& operator*=(const BigInt&);
BigInt& operator/=(const BigInt&);
BigInt& operator%=(const BigInt&);
// Increment and decrement operators:
BigInt& operator++(); // pre-increment
BigInt& operator--(); // pre-decrement
BigInt operator++(int); // post-increment
BigInt operator--(int); // post-decrement
std::strong_ordering operator<=>(const BigInt&) const;
bool operator>(const BigInt&) const = default;
bool operator<(const BigInt&) const = default;
bool operator>=(const BigInt&) const = default;
bool operator<=(const BigInt&) const = default;
bool operator==(const BigInt&) const = default;
bool operator!=(const BigInt&) const = default;
explicit operator uint32_t();
};