![]() |
Apache Ignite C++ Client
|
#include <big_decimal.h>
Public Member Functions | |
| big_decimal (const std::int8_t *mag, std::int32_t len, std::int16_t scale, std::int8_t sign, bool big_endian=true) | |
| big_decimal (const std::byte *data, std::size_t size) | |
| big_decimal (int64_t val) | |
| big_decimal (int64_t val, int16_t scale) | |
| big_decimal (const big_integer &val, int16_t scale) | |
| big_decimal (big_integer &&val, int16_t scale) | |
| big_decimal (const char *val, int32_t len) | |
| big_decimal (const std::string &val) | |
| std::size_t | byte_size () const noexcept |
| void | store_bytes (std::byte *data) const |
| std::vector< std::byte > | to_bytes () const |
| operator double () const | |
| operator int64_t () const | |
| double | to_double () const |
| int64_t | to_int64 () const |
| std::int16_t | get_scale () const noexcept |
| void | set_scale (std::int16_t new_scale, big_decimal &res) const |
| std::int32_t | get_precision () const noexcept |
| const big_integer & | get_unscaled_value () const noexcept |
| void | assign_string (const std::string &val) |
| void | assign_string (const char *val, int32_t len) |
| void | assign_int64 (int64_t val) |
| void | assign_double (double val) |
| void | assign_uint64 (uint64_t val) |
| void | add (const big_decimal &other, big_decimal &res) const |
| void | subtract (const big_decimal &other, big_decimal &res) const |
| void | multiply (const big_decimal &other, big_decimal &res) const |
| void | divide (const big_decimal &other, big_decimal &res) const |
| void | negate () |
| int | compare (const big_decimal &other) const |
| bool | is_negative () const noexcept |
| bool | is_zero () const noexcept |
| bool | is_positive () const noexcept |
Static Public Member Functions | |
| static big_decimal | from_double (double val) |
Friends | |
| void | swap (big_decimal &lhs, big_decimal &rhs) |
| std::ostream & | operator<< (std::ostream &os, const big_decimal &val) |
| std::istream & | operator>> (std::istream &is, big_decimal &val) |
Big decimal number implementation.
TODO: Modernize this code to C++17 and update coding style
|
inline |
Constructor.
| mag | Bytes of the magnitude. Should be positive, sign is passed using separate argument. |
| len | Magnitude length in bytes. |
| scale | Scale. |
| sign | Sign of the decimal. Should be -1 for negative numbers and 1 otherwise. |
| bigEndian | If true then magnitude is in big-endian. Otherwise the byte order of the magnitude considered to be little-endian. |
| ignite::big_decimal::big_decimal | ( | const std::byte * | data, |
| std::size_t | size ) |
Constructs a big decimal from the byte array.
| data | Bytes of the decimal. Scale in little byte order, magnitude as a big_integer. |
| size | The number of bytes. |
|
inlineexplicit |
Integer constructor.
| val | Integer value. |
|
inline |
Integer constructor with scale.
| val | Integer value. |
| scale | Scale. |
|
inline |
big_integer constructor with scale.
| val | big_integer value. |
| scale | Scale. |
|
inline |
big_integer constructor with scale.
| val | big_integer value. |
| scale | Scale. |
|
inlineexplicit |
String constructor.
| val | String to assign. |
| len | String length. |
|
inlineexplicit |
String constructor.
| val | String to assign. |
| void ignite::big_decimal::add | ( | const big_decimal & | other, |
| big_decimal & | res ) const |
Add another big decimal to this.
| other | Addendum. Can be *this. |
| res | Result placed there. Can be *this. |
|
inline |
Assign specified value to this Decimal.
| val | Value to assign. |
|
inline |
Assign specified value to this Decimal.
| val | Value to assign. |
|
inline |
Assign specified value to this Decimal.
| val | String to assign. |
| len | String length. |
|
inline |
Assign specified value to this Decimal.
| val | String to assign. |
|
inline |
Assign specified value to this Decimal.
| val | Value to assign. |
|
nodiscardnoexcept |
Get number of bytes required to store this decimal as byte array.
|
nodiscard |
compare this instance to another.
| other | Another instance. |
| void ignite::big_decimal::divide | ( | const big_decimal & | other, |
| big_decimal & | res ) const |
Divide this to another big decimal.
| divisor | Divisor. Can be *this. |
| res | Result placed there. Can be *this. |
|
inlinestatic |
|
inlinenodiscardnoexcept |
Get precision of the Decimal.
|
inlinenodiscardnoexcept |
Get scale.
|
inlinenodiscardnoexcept |
Get unscaled value.
|
inlinenodiscardnoexcept |
Check whether this value is negative.
|
inlinenodiscardnoexcept |
Check whether this value is positive.
|
inlinenodiscardnoexcept |
Check whether this value is zero.
| void ignite::big_decimal::multiply | ( | const big_decimal & | other, |
| big_decimal & | res ) const |
Muitiply this to another big decimal.
| other | Another instance. Can be *this. |
| res | Result placed there. Can be *this. |
|
inline |
Reverses sign of this value.
|
inlineexplicit |
Convert to double.
|
inlineexplicit |
Convert to int64_t.
| void ignite::big_decimal::set_scale | ( | std::int16_t | new_scale, |
| big_decimal & | res ) const |
Set scale.
| scale | Scale to set. |
| res | Result is placed here. Can be *this. |
| void ignite::big_decimal::store_bytes | ( | std::byte * | data | ) | const |
Store this decimal 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_decimal::subtract | ( | const big_decimal & | other, |
| big_decimal & | res ) const |
Subtract another big decimal from this.
| other | Subtrahend. Can be *this. |
| res | Result placed there. Can be *this. |
|
inlinenodiscard |
Convert value to bytes.
|
inlinenodiscard |
Convert to double.
|
inlinenodiscard |
Convert to int64_t.
|
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 Decimal type.
| other | Other instance. |