mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-07 02:36:47 +00:00
Rework subtraction rounding (again) for more accuracy
- Go back to the old method of computing the mantissa, but when post processing, expand the mantissa to slightly larger than maxMantissa, then in doRoundDown, if the result is not exact, subtract one. Finally, let doNormalize figure out the rounding of the result.
This commit is contained in:
@@ -877,6 +877,26 @@ to_string(MantissaRange::MantissaScale const& scale)
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string
|
||||
to_string(Number::RoundingMode const& round)
|
||||
{
|
||||
switch (round)
|
||||
{
|
||||
enum class RoundingMode { ToNearest, TowardsZero, Downward, Upward };
|
||||
|
||||
case Number::RoundingMode::ToNearest:
|
||||
return "ToNearest";
|
||||
case Number::RoundingMode::TowardsZero:
|
||||
return "TowardsZero";
|
||||
case Number::RoundingMode::Downward:
|
||||
return "Downward";
|
||||
case Number::RoundingMode::Upward:
|
||||
return "Upward";
|
||||
default:
|
||||
throw std::runtime_error("Bad rounding mode");
|
||||
}
|
||||
}
|
||||
|
||||
class SaveNumberRoundMode
|
||||
{
|
||||
Number::RoundingMode mode_;
|
||||
|
||||
Reference in New Issue
Block a user