I am trying to get APR with a set of variables. I was able to break down the formula and do calculation, but i bet it is giving me very wrong calculation, as it output a non numeric in result, like 1234e79. I was wonder if my code is wrong?
where exl,Maths,returnAmount and amount is a variable and not a function. containing result of some other maths done.
The reason, i have link to the code is its private and don’t want it to be indexed (feel free to jsFiddle)
The first step would be to know how to calculate the APR mathematically. I looked up APR and found that there slight differences for that (mostly due to legal restrictions).
once you know the math, then you can think on how to implement that in JavaScript.
@Dormilich yes, but the formula i wrote above is the one i wan’t to use. The payment, months/years are flexible based on user input which will contribute to the calculation of apr. so if i can get help with fixing that formula above
As Math.pow() takes 2 parameters - base and exponent - I think the problem is here 1 + exl(Months,0-returnAmount,amount,0) i.e.
the commas should be operators (+, -, /, *, etc) and there should also be one between exl and the parenthesized variables.
What they should be, I’m sorry to say, I have no idea
That is a numeric result - computers use that format for very huge numbers and very small numbers - the number after the e is the number of places to move the decimal point in the number before the e - the 79 means move the decimal point 79 places to the right in the number before the e to get the answer.
Currently your code shows the total repayable amount of money. I think that it will help if you can explain to me how that relates to the percentage that you seem to desire.
@Paul_Wilkins I don’t know how APR are calculated. Is it the total repayable amount that is applied for APR or just your input amount you put (without any percentages) etc. Although your code shows and explain, what is being computed but suppose if that is what i am getting. How do get the APR in terms of percentage? In short, i want the total repayable amount and other variables that i have computed or entered by user to calculate percentage of APR on that. like you quoted For example 0.056034 is the same as 5.6034%