20#ifndef RIPPLE_PROTOCOL_AMOUNTCONVERSION_H_INCLUDED
21#define RIPPLE_PROTOCOL_AMOUNTCONVERSION_H_INCLUDED
23#include <xrpl/protocol/IOUAmount.h>
24#include <xrpl/protocol/STAmount.h>
25#include <xrpl/protocol/XRPAmount.h>
34 bool const isNeg = iou.
signum() < 0;
48 bool const isNeg = xrp.
signum() < 0;
58 "ripple::toSTAmount : is XRP");
79 "ripple::toAmount<IOUAmount> : maximum mantissa");
84 XRPL_ASSERT(!
isXRP(amt),
"ripple::toAmount<IOUAmount> : is not XRP");
94 "ripple::toAmount<XRPAmount> : maximum mantissa");
99 XRPL_ASSERT(
isXRP(amt),
"ripple::toAmount<XRPAmount> : is XRP");
136 if constexpr (std::is_same_v<IOUAmount, T>)
138 else if constexpr (std::is_same_v<XRPAmount, T>)
140 else if constexpr (std::is_same_v<STAmount, T>)
148 constexpr bool alwaysFalse = !std::is_same_v<T, T>;
149 static_assert(alwaysFalse,
"Unsupported type for toAmount");
157 if constexpr (std::is_same_v<IOUAmount, T>)
159 else if constexpr (std::is_same_v<XRPAmount, T>)
161 else if constexpr (std::is_same_v<STAmount, T>)
170 constexpr bool alwaysFalse = !std::is_same_v<T, T>;
171 static_assert(alwaysFalse,
"Unsupported type for toMaxAmount");
188 if constexpr (std::is_same_v<IOUAmount, T>)
190 else if constexpr (std::is_same_v<XRPAmount, T>)
192 else if constexpr (std::is_same_v<STAmount, T>)
196 constexpr bool alwaysFalse = !std::is_same_v<T, T>;
197 static_assert(alwaysFalse,
"Unsupported type for getIssue");
205 if constexpr (std::is_same_v<IOUAmount, T>)
207 else if constexpr (std::is_same_v<XRPAmount, T>)
209 else if constexpr (std::is_same_v<STAmount, T>)
213 constexpr bool alwaysFalse = !std::is_same_v<T, T>;
214 static_assert(alwaysFalse,
"Unsupported type for get");
Floating point representation of amounts with high dynamic range.
int exponent() const noexcept
int signum() const noexcept
Return the sign of the amount.
std::int64_t mantissa() const noexcept
A currency issued by an account.
constexpr int exponent() const noexcept
static rounding_mode getround()
static rounding_mode setround(rounding_mode mode)
constexpr rep mantissa() const noexcept
int exponent() const noexcept
static const int cMaxOffset
bool negative() const noexcept
std::uint64_t mantissa() const noexcept
static const std::uint64_t cMaxNativeN
static const std::uint64_t cMaxValue
constexpr int signum() const noexcept
Return the sign of the amount.
constexpr value_type drops() const
Returns the number of drops.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
T toAmount(STAmount const &amt)=delete
bool isXRP(AccountID const &c)
STAmount toAmount< STAmount >(STAmount const &amt)
Issue getIssue(T const &amt)
STAmount toSTAmount(IOUAmount const &iou, Issue const &iss)
IOUAmount toAmount< IOUAmount >(STAmount const &amt)
Issue const & noIssue()
Returns an asset specifier that represents no account and currency.
T get(Section const §ion, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
T toMaxAmount(Issue const &issue)
XRPAmount toAmount< XRPAmount >(STAmount const &amt)