|
rippled
|
Floating point representation of amounts with high dynamic range. More...
#include <IOUAmount.h>


Public Member Functions | |
| IOUAmount ()=default | |
| IOUAmount (Number const &other) | |
| IOUAmount (beast::Zero) | |
| IOUAmount (std::int64_t mantissa, int exponent) | |
| IOUAmount & | operator= (beast::Zero) |
| operator Number () const | |
| IOUAmount & | operator+= (IOUAmount const &other) |
| IOUAmount & | operator-= (IOUAmount const &other) |
| IOUAmount | operator- () const |
| bool | operator== (IOUAmount const &other) const |
| bool | operator< (IOUAmount const &other) const |
| operator bool () const noexcept | |
| Returns true if the amount is not zero. More... | |
| int | signum () const noexcept |
| Return the sign of the amount. More... | |
| int | exponent () const noexcept |
| std::int64_t | mantissa () const noexcept |
Static Public Member Functions | |
| static IOUAmount | minPositiveAmount () |
Private Member Functions | |
| void | normalize () |
| Adjusts the mantissa and exponent to the proper range. More... | |
Private Attributes | |
| std::int64_t | mantissa_ |
| int | exponent_ |
Floating point representation of amounts with high dynamic range.
Amounts are stored as a normalized signed mantissa and an exponent. The range of the normalized exponent is [-96,80] and the range of the absolute value of the normalized mantissa is [1000000000000000, 9999999999999999].
Arithmetic operations can throw std::overflow_error during normalization if the amount exceeds the largest representable amount, but underflows will silently trunctate to zero.
Definition at line 43 of file IOUAmount.h.
|
default |
|
explicit |
Definition at line 120 of file IOUAmount.cpp.
| ripple::IOUAmount::IOUAmount | ( | beast::Zero | ) |
Definition at line 102 of file IOUAmount.h.
| ripple::IOUAmount::IOUAmount | ( | std::int64_t | mantissa, |
| int | exponent | ||
| ) |
Definition at line 107 of file IOUAmount.h.
|
private |
Adjusts the mantissa and exponent to the proper range.
This can throw if the amount cannot be normalized, or is larger than the largest value that can be represented as an IOU amount. Amounts that are too small to be represented normalize to 0.
Definition at line 67 of file IOUAmount.cpp.
| IOUAmount & ripple::IOUAmount::operator= | ( | beast::Zero | ) |
Definition at line 114 of file IOUAmount.h.
| ripple::IOUAmount::operator Number | ( | ) | const |
Definition at line 123 of file IOUAmount.h.
Definition at line 130 of file IOUAmount.cpp.
Definition at line 129 of file IOUAmount.h.
| IOUAmount ripple::IOUAmount::operator- | ( | ) | const |
Definition at line 136 of file IOUAmount.h.
| bool ripple::IOUAmount::operator== | ( | IOUAmount const & | other | ) | const |
Definition at line 142 of file IOUAmount.h.
| bool ripple::IOUAmount::operator< | ( | IOUAmount const & | other | ) | const |
Definition at line 147 of file IOUAmount.h.
|
explicitnoexcept |
Returns true if the amount is not zero.
Definition at line 153 of file IOUAmount.h.
|
noexcept |
Return the sign of the amount.
Definition at line 159 of file IOUAmount.h.
|
noexcept |
Definition at line 165 of file IOUAmount.h.
|
noexcept |
Definition at line 171 of file IOUAmount.h.
|
static |
Definition at line 61 of file IOUAmount.cpp.
|
private |
Definition at line 47 of file IOUAmount.h.
|
private |
Definition at line 48 of file IOUAmount.h.