protected static Ptg calcPPMT( Ptg[] operands )
	{
		if( operands.length < 4 )
		{
			return new PtgErr( PtgErr.ERROR_NULL );
		}
			debugOperands( operands, "calcPPMT" );
		double rate = operands[0].getDoubleVal();
		int per = operands[1].getIntVal();
		int nper = operands[2].getIntVal();
		double pv = operands[3].getDoubleVal();
		double fv = 0;
		int type = 0;
		if( (operands.length > 4) && !(operands[4] instanceof PtgMissArg) )
		{
			fv = operands[4].getDoubleVal();
		}
		if( operands.length > 5 )
		{
			type = operands[5].getIntVal();
		}

		double result;
		// 1st, get payment for entire period
		double Rn = Math.pow( 1 + rate, nper );
		double A = (-fv * rate) - (pv * Rn * rate);
		double B = (Rn - 1) * (1 + (rate * type));
		double pmt = A / B;

		double n;
		if( type == 0 )
		{
			n = per;
		}
		else
		{
			n = per - 1;
		}
		// FVa
		A = Math.pow( 1 + rate, n );
		B = pmt * (1 + (rate * type));
		B *= (Math.pow( 1 + rate, n ) - 1) / rate;
		double fva = -((pv * A) + B);
		// FVb
		A = Math.pow( 1 + rate, n - 1 );
		B = pmt * (1 + (rate * type));
		B *= (Math.pow( 1 + rate, n - 1 ) - 1) / rate;
		double fvb = -((pv * A) + B);

		result = fvb - fva;
		PtgNumber pnum = new PtgNumber( result );
			log.debug( "Result from calcPPMT= " + result );
		return pnum;

	}