mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
documents why multiplication is performed first
This commit is contained in:
@@ -252,8 +252,11 @@ loanAccruedInterest(
|
|||||||
auto const secondsSinceLastPayment =
|
auto const secondsSinceLastPayment =
|
||||||
parentCloseTime.time_since_epoch().count() - lastPaymentDate;
|
parentCloseTime.time_since_epoch().count() - lastPaymentDate;
|
||||||
|
|
||||||
return principalOutstanding * periodicRate *
|
// Division is more likely to introduce rounding errors, which will then get
|
||||||
(secondsSinceLastPayment / paymentInterval);
|
// amplified by multiplication. Therefore, we first multiply, and only then
|
||||||
|
// divide.
|
||||||
|
return principalOutstanding * periodicRate * secondsSinceLastPayment /
|
||||||
|
paymentInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Applies a payment to the loan state and returns the breakdown of amounts
|
/* Applies a payment to the loan state and returns the breakdown of amounts
|
||||||
|
|||||||
Reference in New Issue
Block a user