public static double pv(double r, double n, double y, double f, boolean t) {double retval = 0;if (r == 0) {retval = -1*((n*y)+f);}else {double r1 = r + 1;retval =(( ( 1 - Math.pow(r1, n) ) / r ) * (t ? r1 : 1)  * y - f)/Math.pow(r1, n);}return retval;}
public static double pv(double r, double n, double y, double f, bool t){double retval = 0;if (r == 0){retval = -1 * ((n * y) + f);}else{double r1 = r + 1;retval = (((1 - Math.Pow(r1, n)) / r) * (t ? r1 : 1) * y - f)/Math.Pow(r1, n);}return retval;}