| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
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.
| bignumber (const std::string &number_string)
| Parse a std::string of an arbitrary length number into a 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.
| ~bignumber ()=default
| Default destructor.
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.
std::string | get_number (bool hex=false) const
| Get the string representation of the bignumber.

## 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_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

Default destructor.

## Member Function Documentation

## ◆ get_binary()

std::vector< uint64_t > dpp::bignumber::get_binary | ( |  | ) | const

nodiscard

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

nodiscard

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

D++ Library version 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0