Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Javascript PMT with FV

Thread Tools

Javascript PMT with FV
Posts: n/a

I'm writing a script that will output a PMT similar to Excel. I've
searched the net and I've found a code that works, except if a
FutureValue is required.

Here's what I found (can't remember where, sorry)

function pmt_calc( intrest_rate , months , principal_value , fv ) {
pmt = Math.round( (principal_value * intrest_rate) / (1 - Math.pow(1
+ intrest_rate, -months))*100) / 100;
return pmt;

Excel's format is :
Pmt( interest_rate, number_payments, PV, FV, Type )

Any suggestions on how to locate a possible fix to include
FutureValue? Or ideas on how to fix it?

Reply With Quote
Posts: n/a
Oh, some numbers

interest_rate = 0.018125
months = 24
principal_value = 2500
fv = 250

Excel returns 120.98
JS returns 129.39
Reply With Quote
Posts: n/a
Think I found a solution. I'm still going to test it out a bit more,
but for now, it's working perfect.

pmt = Math.round(intrest_rate * -(fv-
(-1+Math.pow((1+intrest_rate),months))*100) / 100;
Reply With Quote
Posts: n/a
When doing $ arithmetic, it's best to do your computations in pennies,
then convert to dollars before you display a result.

The discrepancy is probably in nominal/real rate. 1% per month is 12%
per annum, nominal, but it is 12.68% annually real (compounded
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generated JavaScript vs. Manually Created JavaScript: Which one comes first? Nathan Sokalski ASP .Net 4 11-08-2007 07:24 AM
JavaScript or not JavaScript Mark Rae ASP .Net 36 09-09-2006 01:12 PM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
Javascript -> Applet: variable reset after method call from javascript?! mcdeveloper Java 1 06-13-2006 08:34 AM
Pmt function in C# Justin Martin ASP .Net 3 02-09-2005 06:06 AM