3#include <xrpl/basics/Number.h>
4#include <xrpl/basics/contract.h>
5#include <xrpl/basics/safe_cast.h>
6#include <xrpl/beast/utility/Zero.h>
8#include <boost/multiprecision/cpp_int.hpp>
9#include <boost/operators.hpp>
16class MPTAmount :
private boost::totally_ordered<MPTAmount>,
17 private boost::additive<MPTAmount>,
18 private boost::equality_comparable<MPTAmount, std::int64_t>,
19 private boost::additive<MPTAmount, std::int64_t>
62 operator bool() const noexcept;
96constexpr MPTAmount::operator bool() const noexcept
127 using namespace boost::multiprecision;
130 Throw<std::runtime_error>(
"division by zero");
132 int128_t
const amt128(amt.
value());
133 auto const neg = amt.
value() < 0;
134 auto const m = amt128 * num;
144 Throw<std::overflow_error>(
"MPT mulRatio overflow");
bool operator==(MPTAmount const &other) const
static MPTAmount minPositiveAmount()
MPTAmount & operator-=(MPTAmount const &other)
MPTAmount operator-() const
constexpr int signum() const noexcept
Return the sign of the amount.
constexpr value_type value() const
Returns the underlying value.
MPTAmount(Number const &x)
bool operator<(MPTAmount const &other) const
MPTAmount & operator+=(MPTAmount const &other)
constexpr MPTAmount(MPTAmount const &other)=default
constexpr MPTAmount & operator=(MPTAmount const &other)=default
Number is a floating point type that can represent a wide range of values.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(base_uint< Bits, Tag > const &a)
IOUAmount mulRatio(IOUAmount const &amt, std::uint32_t num, std::uint32_t den, bool roundUp)
Zero allows classes to offer efficient comparisons to zero.