An arbitrary length integer number. Officially, the Discord documentation says that permission values can be any arbitrary number of digits. At time of writing there are only 50 bits of permissions, but this is set to grow larger and potentially past 64 bits. They will continue to send this data as a huge single integer at that point, because this is obviously sensible. /s.
More...
#include <bignum.h>
|
| bignumber ()=default |
| Construct a new bignumber object. More...
|
|
| bignumber (const std::string &number_string) |
| Parse a std::string of an arbitrary length number into a bignumber. More...
|
|
| bignumber (std::vector< uint64_t > bits) |
| Build a bignumber from a vector of 64 bit values. The values are accepted in "reverse order", so the first vector entry at index 0 is the leftmost 64 bits of the bignum. The vector can be any arbitrary length. More...
|
|
| ~bignumber ()=default |
| Default destructor. More...
|
|
std::string | get_number (bool hex=false) const |
| Get the string representation of the bignumber. More...
|
|
std::vector< uint64_t > | get_binary () const |
| Get the array of 64 bit values that represents the bignumber. This is what we should use to store bignumbers in memory, not this bignumber class itself, as the bignumber class instantiates OpenSSL structs and takes significantly more ram than just a vector. More...
|
|
An arbitrary length integer number. Officially, the Discord documentation says that permission values can be any arbitrary number of digits. At time of writing there are only 50 bits of permissions, but this is set to grow larger and potentially past 64 bits. They will continue to send this data as a huge single integer at that point, because this is obviously sensible. /s.
- Note
- dpp::bignumber uses OpenSSL BN_* under the hood, as we include openssl anyway for HTTPS.
◆ bignumber() [1/3]
dpp::bignumber::bignumber |
( |
| ) |
|
|
default |
Construct a new bignumber object.
◆ bignumber() [2/3]
dpp::bignumber::bignumber |
( |
const std::string & |
number_string | ) |
|
Parse a std::string of an arbitrary length number into a bignumber.
- Parameters
-
number_string | string representation of a number. The number must be an integer, and can be positive or negative. |
- Note
- Prefixing number_string with 0x will parse it as hexadecimal. This is not case sensitive.
◆ bignumber() [3/3]
dpp::bignumber::bignumber |
( |
std::vector< uint64_t > |
bits | ) |
|
Build a bignumber from a vector of 64 bit values. The values are accepted in "reverse order", so the first vector entry at index 0 is the leftmost 64 bits of the bignum. The vector can be any arbitrary length.
- Parameters
-
bits | Vector of 64 bit values which represent the number |
◆ ~bignumber()
dpp::bignumber::~bignumber |
( |
| ) |
|
|
default |
◆ get_binary()
std::vector< uint64_t > dpp::bignumber::get_binary |
( |
| ) |
const |
Get the array of 64 bit values that represents the bignumber. This is what we should use to store bignumbers in memory, not this bignumber class itself, as the bignumber class instantiates OpenSSL structs and takes significantly more ram than just a vector.
- Returns
- Vector of 64 bit values representing the bignumber
◆ get_number()
std::string dpp::bignumber::get_number |
( |
bool |
hex = false | ) |
const |
Get the string representation of the bignumber.
- Parameters
-
hex | If false (the default) the number is returned in decimal, else if this parameter is true, it will be returned as hex (without leading '0x') |
- Returns
- String representation of bignumber