Small fixes for Loan merge

- Skip roundToScale work for 0 values.
- Expand a couple of test values to higher precision.
This commit is contained in:
Ed Hennis
2025-12-03 20:01:06 -05:00
parent 7863cc71cc
commit daf0316600
2 changed files with 6 additions and 2 deletions

View File

@@ -1473,6 +1473,10 @@ roundToScale(
if (value.integral())
return value;
// Nothing to do for zero.
if (value == beast::zero)
return value;
// If the value's exponent is greater than or equal to the scale, then
// rounding will do nothing, and might even lose precision, so just return
// the value.

View File

@@ -2392,7 +2392,7 @@ protected:
interval * Number(12, -2) / secondsInYear;
BEAST_EXPECT(
periodicRate ==
Number(2283105022831050, -21, Number::unchecked{}));
Number(2283105022831050228ULL, -24, Number::normalized{}));
STAmount const principalOutstanding{
broker.asset, state.principalOutstanding};
STAmount const accruedInterest{
@@ -2624,7 +2624,7 @@ protected:
interval * Number(12, -2) / secondsInYear;
BEAST_EXPECT(
periodicRate ==
Number(2283105022831050, -21, Number::unchecked{}));
Number(2283105022831050228, -24, Number::normalized{}));
STAmount const roundedPeriodicPayment{
broker.asset,
roundPeriodicPayment(