Created
January 25, 2013 23:27
-
-
Save ghalimi/4638848 to your computer and use it in GitHub Desktop.
PV Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function PV(rate, periods, payment, future, type) { | |
// Initialize type | |
var type = (typeof type === 'undefined') ? 0 : type; | |
// Evaluate rate and periods (TODO: replace with secure expression evaluator) | |
rate = eval(rate); | |
periods = eval(periods); | |
// Return present value | |
if (rate === 0) { | |
return - payment * periods - future; | |
} else { | |
return (((1 - Math.pow(1 + rate, periods)) / rate) * payment * (1 +rate * type) - future) / Math.pow(1 + rate, periods); | |
} | |
} |
hey, thanks!
thanks cezarlz
thanks
thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, nice script!
This function is more simple? No?
Thanks!