31 #ifndef LEDGER_CORE_BIGINT_H 32 #define LEDGER_CORE_BIGINT_H 34 #ifndef LIBCORE_EXPORT 36 #include <libcore_export.h> 38 #define LIBCORE_EXPORT 46 #include "../utils/endian.h" 59 static LIBCORE_EXPORT
const BigInt ZERO;
60 static LIBCORE_EXPORT
const BigInt ONE;
61 static LIBCORE_EXPORT
const BigInt TEN;
62 typedef unsigned int SimpleInt;
63 typedef unsigned long DoubleInt;
67 static LIBCORE_EXPORT
const std::string
DIGITS;
101 static LIBCORE_EXPORT
BigInt fromString(
const std::string& str);
103 template <
typename T>
104 static BigInt fromScalar(T value) {
106 result.assignScalar<T>(value);
111 BigInt(
const std::string& str,
int radix);
115 static bool all_digits(std::string
const& s);
128 BigInt(
const void *data,
size_t length,
bool negative);
129 BigInt(
const std::vector<uint8_t>& data,
bool negative);
137 explicit BigInt(
int value);
138 explicit BigInt(
unsigned int value);
139 explicit BigInt(
unsigned long long value);
140 explicit BigInt(int64_t value);
146 BigInt(
const std::string& str);
160 uint64_t toUint64()
const;
161 int64_t toInt64()
const;
170 std::string to_string()
const {
return toString();};
198 bool operator<(
const BigInt&)
const;
199 bool operator<=(
const BigInt&)
const;
200 bool operator==(
const BigInt&)
const;
201 bool operator>(
const BigInt&)
const;
202 bool operator>=(
const BigInt&)
const;
204 int compare(
const BigInt&)
const;
206 BigInt pow(
unsigned short p)
const;
208 unsigned long getBitSize()
const;
209 bool isNegative()
const;
210 bool isPositive()
const;
215 BigInt& assignI64(int64_t value);
217 template <
typename T>
218 BigInt& assignScalar(T value) {
219 auto bytes = endianness::scalar_type_to_array<T>(std::abs(value), endianness::Endianness::BIG);
220 bdConvFromOctets(_bigd, reinterpret_cast<const unsigned char *>(bytes),
sizeof(value));
222 _negative = value < 0LL;
235 #endif //LEDGER_CORE_BIGINT_H std::string toHexString() const
Definition: BigInt.cpp:151
unsigned toUnsignedInt() const
Definition: BigInt.cpp:136
static LIBCORE_EXPORT const std::string DIGITS
Definition: BigInt.h:67
std::string toString() const
Definition: BigInt.cpp:140
int toInt() const
Definition: BigInt.cpp:132
static LIBCORE_EXPORT const int MIN_RADIX
Definition: BigInt.h:71
std::vector< uint8_t > toByteArray() const
Definition: BigInt.cpp:342
static LIBCORE_EXPORT BigInt fromDecimal(const std::string &str)
Definition: BigInt.cpp:382
Definition: Account.cpp:8
static LIBCORE_EXPORT BigInt * from_hex(const std::string &str)
Definition: BigInt.cpp:166
static LIBCORE_EXPORT const int MAX_RADIX
Definition: BigInt.h:75
static LIBCORE_EXPORT BigInt fromHex(const std::string &str)
Definition: BigInt.cpp:378
static LIBCORE_EXPORT BigInt * from_dec(const std::string &str)
Definition: BigInt.cpp:170