ledger-core
|
#include <ledger/core/math/BigInt.h>
Public Types | |
typedef unsigned int | SimpleInt |
typedef unsigned long | DoubleInt |
Public Member Functions | |
BigInt (const BigInt &cpy) | |
BigInt (BigInt &&mov) | |
BigInt (const void *data, size_t length, bool negative) | |
BigInt (const std::vector< uint8_t > &data, bool negative) | |
BigInt (int value) | |
BigInt (unsigned int value) | |
BigInt (unsigned long long value) | |
BigInt (int64_t value) | |
BigInt (const std::string &str) | |
int | toInt () const |
unsigned | toUnsignedInt () const |
uint64_t | toUint64 () const |
int64_t | toInt64 () const |
std::string | toString () const |
std::string | to_string () const |
std::string | toHexString () const |
std::vector< uint8_t > | toByteArray () const |
BigInt | operator+ (const BigInt &rhs) const |
BigInt | operator- (const BigInt &rhs) const |
BigInt | operator* (const BigInt &rhs) const |
BigInt | operator/ (const BigInt &rhs) const |
BigInt | operator% (const BigInt &rhs) const |
BigInt & | operator++ () |
BigInt | operator++ (int) |
BigInt & | operator-- () |
BigInt | operator-- (int) |
BigInt & | operator= (const BigInt &) |
BigInt & | operator= (BigInt &&a) |
bool | operator< (const BigInt &) const |
bool | operator<= (const BigInt &) const |
bool | operator== (const BigInt &) const |
bool | operator> (const BigInt &) const |
bool | operator>= (const BigInt &) const |
int | compare (const BigInt &) const |
BigInt | pow (unsigned short p) const |
unsigned long | getBitSize () const |
bool | isNegative () const |
bool | isPositive () const |
bool | isZero () const |
BigInt | negative () const |
BigInt | positive () const |
BigInt & | assignI64 (int64_t value) |
template<typename T > | |
BigInt & | assignScalar (T value) |
Static Public Member Functions | |
static LIBCORE_EXPORT BigInt * | from_hex (const std::string &str) |
static LIBCORE_EXPORT BigInt | fromHex (const std::string &str) |
static LIBCORE_EXPORT BigInt * | from_dec (const std::string &str) |
static LIBCORE_EXPORT BigInt | fromDecimal (const std::string &str) |
static LIBCORE_EXPORT BigInt | fromString (const std::string &str) |
template<typename T > | |
static BigInt | fromScalar (T value) |
Static Public Attributes | |
static LIBCORE_EXPORT const BigInt | ZERO = BigInt(0) |
static LIBCORE_EXPORT const BigInt | ONE = BigInt(1) |
static LIBCORE_EXPORT const BigInt | TEN = BigInt(10) |
static LIBCORE_EXPORT const std::string | DIGITS = std::string("0123456789abcdefghijklmnopqrstuvwxyz") |
static LIBCORE_EXPORT const int | MIN_RADIX = 2 |
static LIBCORE_EXPORT const int | MAX_RADIX = 36 |
Helper class used to deal with really big integers.
ledger::core::BigInt::BigInt | ( | const void * | data, |
size_t | length, | ||
bool | negative | ||
) |
Initializes a new BigInt with the given big endian data.
data | The big integer data formatted in big endian |
length | The length of the data |
negative | true if the number is negative false otherwise |
|
explicit |
ledger::core::BigInt::BigInt | ( | const std::string & | str | ) |
|
static |
Creates a new BigInt from the given decimal encoded string.
str | The number encoded in decimal (e.g. "125") |
|
static |
|
static |
Creates a new BigInt from the given decimal encoded string.
str | The number encoded in decimal (e.g. "125") |
|
static |
Creates a new BigInt from the given hexadecimal encoded string.
str | The number encoded in hexadecimal (e.g. "E0A1B3") |
std::vector< uint8_t > ledger::core::BigInt::toByteArray | ( | ) | const |
Serializes the BigInt into a Big Endian byte array.
std::string ledger::core::BigInt::toHexString | ( | ) | const |
Serializes the BigInt into a hexadecimal std::string.
int ledger::core::BigInt::toInt | ( | ) | const |
Converts the BigInt to int
std::string ledger::core::BigInt::toString | ( | ) | const |
unsigned int ledger::core::BigInt::toUnsignedInt | ( | ) | const |
Converts the BigInt to unsigned int
|
static |
Available digits for conversion to and from strings.
|
static |
The minimum radix available for conversion to and from strings.
|
static |
The maximum radix available for conversion to and from strings.