![]() |
Apache Ignite C++ Client
|
#include <big_integer.h>
Public Types | |
| using | mag_array_view = mpi_t::mag_view |
Public Member Functions | |
| big_integer ()=default | |
| big_integer (const big_integer &other)=default | |
| big_integer (big_integer &&other) noexcept=default | |
| big_integer (std::int64_t val) | |
| big_integer (const std::string &val) | |
| big_integer (const char *val, std::int32_t len) | |
| big_integer (const std::int8_t *val, std::int32_t len, std::int8_t sign, bool big_endian=true) | |
| big_integer (const std::byte *data, std::size_t size) | |
| big_integer & | operator= (const big_integer &other)=default |
| big_integer & | operator= (big_integer &&other) noexcept=default |
| big_integer & | operator= (const mpi_t &other) |
| big_integer & | operator= (mpi_t &&other) noexcept |
| void | assign_int64 (std::int64_t val) |
| void | assign_uint64 (std::uint64_t val) |
| void | assign_string (const std::string &val) |
| void | assign_string (const char *val, std::size_t len) |
| std::int8_t | get_sign () const noexcept |
| mag_array_view | get_magnitude () const noexcept |
| std::uint32_t | bit_length () const noexcept |
| std::size_t | byte_size () const noexcept |
| void | store_bytes (std::byte *data) const |
| std::vector< std::byte > | to_bytes () const |
| std::int32_t | get_precision () const noexcept |
| void | pow (std::int32_t exp) |
| void | multiply (const big_integer &other, big_integer &res) const |
| void | divide (const big_integer &divisor, big_integer &res) const |
| void | divide (const big_integer &divisor, big_integer &res, big_integer &rem) const |
| void | add (const big_integer &other, big_integer &res) const |
| void | subtract (const big_integer &other, big_integer &res) const |
| void | add (std::uint64_t x) |
| int | compare (const big_integer &other, bool ignore_sign=false) const |
| std::int64_t | to_int64 () const |
| bool | is_negative () const noexcept |
| bool | is_zero () const noexcept |
| bool | is_positive () const noexcept |
| void | negate () |
| std::string | to_string () const |
Static Public Member Functions | |
| static void | get_power_of_ten (std::int32_t pow, big_integer &res) |
Friends | |
| class | big_decimal |
| std::ostream & | operator<< (std::ostream &os, const big_integer &val) |
| std::istream & | operator>> (std::istream &is, big_integer &val) |
| void | swap (big_integer &lhs, big_integer &rhs) |
Big integer number implementation.
TODO: Modernize this code to C++17 and update coding style
|
default |
Default constructor. Constructs zero-value big integer.
|
default |
Copy constructor.
| other | Other value. |
|
defaultnoexcept |
Move constructor.
| other | Other value. |
|
inlineexplicit |
Constructs big integer with the specified integer value.
| val | Value. |
|
inlineexplicit |
String constructor.
| val | String to assign. |
|
inline |
String constructor.
| val | String to assign. |
| len | String length. |
| ignite::big_integer::big_integer | ( | const std::int8_t * | val, |
| std::int32_t | len, | ||
| std::int8_t | sign, | ||
| bool | big_endian = true ) |
Constructs big integer from the byte array.
| val | Bytes of the integer. Byte order is big-endian. |
| len | Array length. |
| sign | Signum. Can be -1 (negative) or 1 (positive or zero). |
| bigEndian | If true then magnitude is in big-endian. Otherwise the byte order of the magnitude considered to be little-endian. |
| ignite::big_integer::big_integer | ( | const std::byte * | data, |
| std::size_t | size ) |
Constructs a big integer from the byte array.
| data | Bytes of the integer. Byte order is big-endian. The representation is two's-complement. |
| size | The number of bytes. |
| void ignite::big_integer::add | ( | const big_integer & | other, |
| big_integer & | res ) const |
Add another big integer to this.
| other | Addendum. Can be *this. |
| res | Result placed there. Can be *this. |
| void ignite::big_integer::add | ( | std::uint64_t | x | ) |
Add unsigned integer number to this big_integer.
| x | Number to add. |
| void ignite::big_integer::assign_int64 | ( | std::int64_t | val | ) |
Assign specified value to this big_integer.
| val | Value to assign. |
| void ignite::big_integer::assign_string | ( | const char * | val, |
| std::size_t | len ) |
Assign specified value to this Decimal.
| val | String to assign. |
| len | String length. |
| void ignite::big_integer::assign_string | ( | const std::string & | val | ) |
Assign specified value to this Decimal.
| val | String to assign. |
| void ignite::big_integer::assign_uint64 | ( | std::uint64_t | val | ) |
Assign specified value to this big_integer.
| val | Value to assign. |
|
nodiscardnoexcept |
Get length in bits of the two's-complement representation of this number, excluding a sign bit.
|
nodiscardnoexcept |
Get number of bytes required to store this number as byte array.
|
nodiscard |
compare this instance to another.
| other | Another instance. |
| ignore_sign | If set to true than only magnitudes are compared. |
| void ignite::big_integer::divide | ( | const big_integer & | divisor, |
| big_integer & | res ) const |
Divide this to another big integer.
| divisor | Divisor. Can be *this. |
| res | Result placed there. Can be *this. |
| void ignite::big_integer::divide | ( | const big_integer & | divisor, |
| big_integer & | res, | ||
| big_integer & | rem ) const |
Divide this to another big integer.
| divisor | Divisor. Can be *this. |
| res | Result placed there. Can be *this. |
| rem | Remainder placed there. Can be *this. |
|
inlinenodiscardnoexcept |
Get magnitude array.
|
static |
Get big_integer which value is the ten of the specified power.
| pow | Tenth power. |
| res | Result is placed here. |
|
nodiscardnoexcept |
Get precision of the BigInteger.
|
inlinenodiscardnoexcept |
Get number sign. Returns -1 if negative and 1 otherwise.
|
inlinenodiscardnoexcept |
Check whether this value is negative.
|
inlinenodiscardnoexcept |
Check whether this value is positive.
|
inlinenodiscardnoexcept |
Check whether this value is zero.
| void ignite::big_integer::multiply | ( | const big_integer & | other, |
| big_integer & | res ) const |
Muitiply this to another big integer.
| other | Another instance. Can be *this. |
| res | Result placed there. Can be *this. |
|
inline |
Reverses sign of this value.
|
defaultnoexcept |
Move-assigment operator.
| other | Other value. |
|
default |
Copy-assigment operator.
| other | Other value. |
|
inline |
Copy-assigment operator.
| other | Other value. |
|
inlinenoexcept |
Move-assigment operator.
| other | Other value. |
| void ignite::big_integer::pow | ( | std::int32_t | exp | ) |
Mutates this BigInteger so its value becomes exp power of this.
| exp | Exponent. |
| void ignite::big_integer::store_bytes | ( | std::byte * | data | ) | const |
Store this number as a byte array.
| data | Destination byte array. Its size must be at least as large as the value returned by byte_size(); |
| void ignite::big_integer::subtract | ( | const big_integer & | other, |
| big_integer & | res ) const |
Subtract another big integer from this.
| other | Subtrahend. Can be *this. |
| res | Result placed there. Can be *this. |
|
inlinenodiscard |
Convert value to bytes.
|
nodiscard |
Convert to int64_t.
|
nodiscard |
Converts value to string.
|
friend |
Output operator.
| os | Output stream. |
| val | Value to output. |
|
friend |
Input operator.
| is | Input stream. |
| val | Value to input. |
|
friend |
Swap function for the big_integer type.
| other | Other instance. |