D++ (DPP)
C++ Discord API Bot Library
dpp::bignumber Class Reference

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>

Public Member Functions

 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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_stringstring 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
bitsVector of 64 bit values which represent the number

◆ ~bignumber()

dpp::bignumber::~bignumber ( )
default

Default destructor.

Member Function Documentation

◆ 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
hexIf 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
D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0