mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-07 02:36:47 +00:00
Fix formatting, add an assert
This commit is contained in:
@@ -473,6 +473,9 @@ Number::Guard::doRoundDown(bool& negative, T& mantissa, int& exponent)
|
||||
{
|
||||
// If there was any remainder, subtract 1 from the result. This is sufficient to get the
|
||||
// best rounding.
|
||||
XRPL_ASSERT(
|
||||
empty() || mantissa > maxMantissa_,
|
||||
"xrpl::Number::Guard::doRoundDown : mantissa is expected size");
|
||||
if (r != Round::Exact)
|
||||
{
|
||||
--mantissa;
|
||||
|
||||
@@ -1981,14 +1981,19 @@ public:
|
||||
case MantissaRange::MantissaScale::Small:
|
||||
case MantissaRange::MantissaScale::LargeLegacy: {
|
||||
// Without the fix, all the results but one round up
|
||||
for (auto const& [r, sum] : sums) {
|
||||
if (r == Number::RoundingMode::Downward) {
|
||||
// Downward works because the Guard sign is negative, and Downward returns Up
|
||||
// instead of Down if negative and there's a remainder, whereas TowardsZero
|
||||
// always returns Down.
|
||||
BEAST_EXPECTS(sums.at(Number::RoundingMode::Downward).first < exact, to_string(r));
|
||||
for (auto const& [r, sum] : sums)
|
||||
{
|
||||
if (r == Number::RoundingMode::Downward)
|
||||
{
|
||||
// Downward works because the Guard sign is negative, and Downward
|
||||
// returns Up instead of Down if negative and there's a remainder,
|
||||
// whereas TowardsZero always returns Down.
|
||||
BEAST_EXPECTS(
|
||||
sums.at(Number::RoundingMode::Downward).first < exact,
|
||||
to_string(r));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
BEAST_EXPECTS(sums.at(r).first > exact, to_string(r));
|
||||
}
|
||||
}
|
||||
@@ -2058,14 +2063,19 @@ public:
|
||||
{
|
||||
case MantissaRange::MantissaScale::Small:
|
||||
case MantissaRange::MantissaScale::LargeLegacy: {
|
||||
for (auto const& [r, sum] : sums) {
|
||||
if (r == Number::RoundingMode::Downward) {
|
||||
// Downward works because the Guard sign is negative, and Downward returns Up
|
||||
// instead of Down if negative and there's a remainder, whereas TowardsZero
|
||||
// always returns Down.
|
||||
BEAST_EXPECTS(sums.at(Number::RoundingMode::Downward).first < exact, to_string(r));
|
||||
for (auto const& [r, sum] : sums)
|
||||
{
|
||||
if (r == Number::RoundingMode::Downward)
|
||||
{
|
||||
// Downward works because the Guard sign is negative, and Downward
|
||||
// returns Up instead of Down if negative and there's a remainder,
|
||||
// whereas TowardsZero always returns Down.
|
||||
BEAST_EXPECTS(
|
||||
sums.at(Number::RoundingMode::Downward).first < exact,
|
||||
to_string(r));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
BEAST_EXPECTS(sums.at(r).first > exact, to_string(r));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user