mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Fix revert issues
This commit is contained in:
@@ -13,6 +13,15 @@ class Number;
|
|||||||
std::string
|
std::string
|
||||||
to_string(Number const& amount);
|
to_string(Number const& amount);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr bool
|
||||||
|
isPowerOfTen(T value)
|
||||||
|
{
|
||||||
|
while (value >= 10 && value % 10 == 0)
|
||||||
|
value /= 10;
|
||||||
|
return value == 1;
|
||||||
|
}
|
||||||
|
|
||||||
class Number
|
class Number
|
||||||
{
|
{
|
||||||
using rep = std::int64_t;
|
using rep = std::int64_t;
|
||||||
@@ -22,7 +31,9 @@ class Number
|
|||||||
public:
|
public:
|
||||||
// The range for the mantissa when normalized
|
// The range for the mantissa when normalized
|
||||||
constexpr static std::int64_t minMantissa = 1'000'000'000'000'000LL;
|
constexpr static std::int64_t minMantissa = 1'000'000'000'000'000LL;
|
||||||
constexpr static std::int64_t maxMantissa = 9'999'999'999'999'999LL;
|
static_assert(isPowerOfTen(minMantissa));
|
||||||
|
constexpr static std::int64_t maxMantissa = minMantissa * 10 - 1;
|
||||||
|
static_assert(maxMantissa == 9'999'999'999'999'999LL);
|
||||||
|
|
||||||
// The range for the exponent when normalized
|
// The range for the exponent when normalized
|
||||||
constexpr static int minExponent = -32768;
|
constexpr static int minExponent = -32768;
|
||||||
|
|||||||
@@ -84,6 +84,12 @@ public:
|
|||||||
return holds<Issue>() && get<Issue>().native();
|
return holds<Issue>() && get<Issue>().native();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
integral() const
|
||||||
|
{
|
||||||
|
return !holds<Issue>() || get<Issue>().native();
|
||||||
|
}
|
||||||
|
|
||||||
friend constexpr bool
|
friend constexpr bool
|
||||||
operator==(Asset const& lhs, Asset const& rhs);
|
operator==(Asset const& lhs, Asset const& rhs);
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,9 @@ public:
|
|||||||
int
|
int
|
||||||
exponent() const noexcept;
|
exponent() const noexcept;
|
||||||
|
|
||||||
|
bool
|
||||||
|
integral() const noexcept;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
native() const noexcept;
|
native() const noexcept;
|
||||||
|
|
||||||
@@ -437,6 +440,12 @@ STAmount::exponent() const noexcept
|
|||||||
return mOffset;
|
return mOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
STAmount::integral() const noexcept
|
||||||
|
{
|
||||||
|
return mAsset.integral();
|
||||||
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
STAmount::native() const noexcept
|
STAmount::native() const noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -834,6 +834,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
testZero();
|
testZero();
|
||||||
|
|||||||
Reference in New Issue
Block a user