You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Money is usually used in context when a percent is computed on some money value, for example to compute an interest amount.
A Percent type could be added as a companion abstraction for money.
// Percent is a 3 decimal percent value. Internally it is stored as an int64 with a 3 digits scale// interestRate := percent.FromStr("3.5")// It represents a 3.5% (a 0.03500) factor, and stored as 3500typePercentint64constScale=1000constScaledPercentToRate=100*Scalefunc (pPercent) By(amount fpmoney.Amount) (computed fpmoney.Amount, remainder fpmoney.Amount) {
returnamount.Mul(int(p)).Div(ScaledPercentToRate)
}
Additional methods will be provided.
What do you think?
I can provide a PR.
The text was updated successfully, but these errors were encountered:
Hi, yes, that is useful too. But I am not sure how much precision is necessary. I could imagine people want to have more than 1 fraction decimal for percentages.
Let's keep fpamount to deal only with {"amount" ... "currency"} pairs.
Do recommend for you to create new module / repo for percentages though if you are interested! :D
Money is usually used in context when a percent is computed on some money value, for example to compute an interest amount.
A Percent type could be added as a companion abstraction for money.
Additional methods will be provided.
What do you think?
I can provide a PR.
The text was updated successfully, but these errors were encountered: