20#ifndef RIPPLE_PROTOCOL_MPTAMOUNT_H_INCLUDED
21#define RIPPLE_PROTOCOL_MPTAMOUNT_H_INCLUDED
23#include <xrpl/basics/Number.h>
24#include <xrpl/basics/contract.h>
25#include <xrpl/basics/safe_cast.h>
26#include <xrpl/beast/utility/Zero.h>
28#include <boost/multiprecision/cpp_int.hpp>
29#include <boost/operators.hpp>
36class MPTAmount :
private boost::totally_ordered<MPTAmount>,
37 private boost::additive<MPTAmount>,
38 private boost::equality_comparable<MPTAmount, std::int64_t>,
39 private boost::additive<MPTAmount, std::int64_t>
82 operator bool() const noexcept;
116constexpr MPTAmount::operator bool() const noexcept
151 using namespace boost::multiprecision;
154 Throw<std::runtime_error>(
"division by zero");
156 int128_t
const amt128(amt.
value());
157 auto const neg = amt.
value() < 0;
158 auto const m = amt128 * num;
168 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.