protected static Ptg calcQuartile( Ptg[] operands )
	{
		Ptg[] aveoperands = new Ptg[1];
		aveoperands[0] = operands[0];
		Ptg[] allVals = PtgCalculator.getAllComponents( aveoperands );
		CompatibleVector t = new CompatibleVector();
		double retval = 0;
		for( Ptg p : allVals )
		{
			try
			{
				Double d = new Double( String.valueOf( p.getValue() ) );
				t.addOrderedDouble( d );
			}
			catch( NumberFormatException e )
			{
				log.error( "calcQuartile error", e );
			}
		}

		Double[] dub = new Double[t.size()];
		t.toArray( dub );
		Integer quart;
		Object o = operands[1].getValue();
		if( o instanceof Integer )
		{
			quart = (Integer) operands[1].getValue();
		}
		else
		{
			quart = ((Double) operands[1].getValue()).intValue();
		}

		float quartile = quart.floatValue();
		if( quart == 0 )
		{    // return minimum value
			return new PtgNumber( dub[0] );
		}
		if( quart == 4 )
		{    // return maximum value
			return new PtgNumber( dub[t.size() - 1] );
		}
		if( (quart > 4) || (quart < 0) )
		{
			return new PtgErr( PtgErr.ERROR_NUM );
		}
		// find the kth smallest
		float kk = quartile / 4;
		kk = (dub.length - 1) * kk;
		kk++;
		// truncate k, but keep the remainder.
		int k = -1;
		float remainder = 0;
		if( (kk % 1) != 0 )
		{
			remainder = kk % 1;
			String s = String.valueOf( kk );
			String ss = s.substring( s.indexOf( "." ), s.length() );
			ss = "0" + ss;
			remainder = new Float( ss );
			s = s.substring( 0, s.indexOf( "." ) );
			k = Integer.valueOf( String.valueOf( s ) );
		}
		else
		{
			k = (int) kk / 1;
		}
		if( k >= dub.length )
		{
			return new PtgErr( PtgErr.ERROR_VALUE );
		}
		double firstVal = dub[k - 1];
		double secondVal = dub[k];
		double output = firstVal + (remainder * (secondVal - firstVal));
		PtgNumber pn = new PtgNumber( output );
		return pn;
	}