mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
documents why multiplication is performed first
This commit is contained in:
@@ -252,8 +252,11 @@ loanAccruedInterest(
|
||||
auto const secondsSinceLastPayment =
|
||||
parentCloseTime.time_since_epoch().count() - lastPaymentDate;
|
||||
|
||||
return principalOutstanding * periodicRate *
|
||||
(secondsSinceLastPayment / paymentInterval);
|
||||
// Division is more likely to introduce rounding errors, which will then get
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user