-
Notifications
You must be signed in to change notification settings - Fork 0
/
bignum.h
62 lines (45 loc) · 1014 Bytes
/
bignum.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
#ifndef BIGNUM_H
#define BIGNUM_H
#include <cstdint>
class BigNum
{
public:
BigNum();
virtual std::int_fast8_t cmp(const BigNum &op, bool ignore_lt = false, bool ignore_gt = false) = 0;
};
#include <string>
#include <vector>
class BigNumDiscrete
{
public:
BigNumDiscrete()
{}
/*
bool from_string(std::string num, unsigned int base)
{
std::string::iterator i = num.crbegin();
std::uint64_t cur = 0;
std::uint64_t prod = 1;
while (i != num.crend())
{
unsigned int digit = *i - '0';
if (digit >= base) {return false;}
cur += digit * prod;
prod *= base;
if (prod > 0xFFFFFFFF)
{
}
i++;
}
negative = (i != num.cend() && *i == '-');
if (negative) {i++;}
while (i != num.cend())
{
i++;
}
}
*/
bool negative;
std::vector<std::uint32_t> parts;
};
#endif // BIGNUM_H