We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have an expression like this -> "(0.341 * 8000.0) / (1 - (1 + 0.341) ^ -84)"
Expected result - "109.71908469357446" Actual result - "1.538906384258725e-36"
calculation should be done like below snippet
fun calculateMonthlyInstallment(loanAmount: Double, monthlyInterestRate: Double, numberOfMonths: Int): Double { val monthlyInterestRateDecimal = monthlyInterestRate / 100.0 // Convert percentage to decimal val power = Math.pow(1 + monthlyInterestRateDecimal, -numberOfMonths.toDouble()) return (monthlyInterestRateDecimal * loanAmount) / (1 - power) } fun main() { val loanAmount = 8000.0 val monthlyInterestRate = 0.341 // 0.5% interest rate val numberOfMonths = 84 val monthlyInstallment = calculateMonthlyInstallment(loanAmount, monthlyInterestRate, numberOfMonths) println("Monthly Installment: $monthlyInstallment") }
The text was updated successfully, but these errors were encountered:
Wolfram Alpha says that the result should be 2728?
If I'm not mistaken (which might be, am tired) then your code comes out as:
((0.341 / 100.0) * 8000.0) / (1 - ((1 + (341.0 / 100.0)) ^ -84))
which results in 27.28.
27.28
Sorry, something went wrong.
Having said that, both expressions are correctly evaluated by exp4j (0.4.8):
(0.341 * 8000.0) / (1 - (1 + 0.341) ^ -84) = 2728 ((0.341 / 100.0) * 8000.0) / (1 - ((1 + (341.0 / 100.0)) ^ -84)) = 27.28
I get the exact same result from the "bc" linux utility:
~/dev/repos/dev story-ss-312…enkins-build *2 ?1 bc -lq ✔ 2 task 15:44:15 >>> (0.341 * 8000.0) / (1 - (1 + 0.341) ^ -84) 2728.00000005392957854258 >>> ((0.341 / 100.0) * 8000.0) / (1 - ((1 + (341.0 / 100.0)) ^ -84)) 27.28000000000000000000 >>>
exp4j is evaluating correctly the expression.
No branches or pull requests
I have an expression like this -> "(0.341 * 8000.0) / (1 - (1 + 0.341) ^ -84)"
Expected result - "109.71908469357446"
Actual result - "1.538906384258725e-36"
calculation should be done like below snippet
The text was updated successfully, but these errors were encountered: