1#ifndef XRPL_PROTOCOL_MPTAMOUNT_H_INCLUDED
2#define XRPL_PROTOCOL_MPTAMOUNT_H_INCLUDED
4#include <xrpl/basics/Number.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/basics/safe_cast.h>
7#include <xrpl/beast/utility/Zero.h>
9#include <boost/multiprecision/cpp_int.hpp>
10#include <boost/operators.hpp>
17class MPTAmount :
private boost::totally_ordered<MPTAmount>,
18 private boost::additive<MPTAmount>,
19 private boost::equality_comparable<MPTAmount, std::int64_t>,
20 private boost::additive<MPTAmount, std::int64_t>
63 operator bool() const noexcept;
97constexpr MPTAmount::operator bool() const noexcept
132 using namespace boost::multiprecision;
135 Throw<std::runtime_error>(
"division by zero");
137 int128_t
const amt128(amt.
value());
138 auto const neg = amt.
value() < 0;
139 auto const m = amt128 * num;
149 Throw<std::overflow_error>(
"MPT mulRatio overflow");
constexpr value_type value() const
Returns the underlying value.
bool operator==(MPTAmount const &other) const
MPTAmount & operator-=(MPTAmount const &other)
constexpr MPTAmount & operator=(MPTAmount const &other)=default
MPTAmount operator-() const
bool operator<(MPTAmount const &other) const
constexpr int signum() const noexcept
Return the sign of the amount.
MPTAmount & operator+=(MPTAmount const &other)
constexpr MPTAmount(MPTAmount const &other)=default
MPTAmount(Number const &x)
static MPTAmount minPositiveAmount()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
IOUAmount mulRatio(IOUAmount const &amt, std::uint32_t num, std::uint32_t den, bool roundUp)
std::string to_string(base_uint< Bits, Tag > const &a)
Zero allows classes to offer efficient comparisons to zero.