I have a standard formula for calculating loan amortization schedule.
Here is the formula:
(Px(i/12))/(1-(1+i/12)^-n)
Here is what I have in ruby:
p = BigDecimal('1000.0')
n = BigDecimal('12')
i = BigDecimal('3')
m = (p * (i/12))/(1-(1+i/12) ** -n)
I’m getting a following error: in `**’: wrong argument type BigDecimal (expected Fixnum) (TypeError)
I’m having hard time trying to play with Fixnun, Float and BigDecimal in ruby.
n must be an integer per definition if you want to use
**akaBigDecimal#power(n)PS: I just looked up your formula on wikipedia. Since n is the number of payments, it will be an integer by nature so just use a Fixnum for n – you won’t get any troubles 🙂