protected static Ptg calcMedian( Ptg[] operands )
	{
		if( operands.length < 1 )
		{
			return new PtgErr( PtgErr.ERROR_VALUE );
		}
		Ptg[] alloperands = PtgCalculator.getAllComponents( operands );
		CompatibleVector t = new CompatibleVector();
		double retval = 0;
		for( Ptg p : alloperands )
		{
			try
			{
				Double d = new Double( String.valueOf( p.getValue() ) );
				t.addOrderedDouble( d );
			}
			catch( NumberFormatException e )
			{
			}
			;
		}

		try
		{
			Double[] dub = new Double[t.size()];
			t.toArray( dub );
			double dd = (double) t.size() % 2;
			if( ((double) t.size() % 2) == 0 )
			{
				int firstValLoc = ((t.size()) / 2) - 1;
				int lastValLoc = firstValLoc + 1;
				double firstVal = dub[firstValLoc];
				double lastVal = dub[lastValLoc];
				retval = (firstVal + lastVal) / 2;
			}
			else
			{
				// it's odd
				int firstValLoc = ((t.size() - 1) / 2);
				double firstVal = dub[firstValLoc];
				retval = firstVal;
			}
			PtgNumber pnum = new PtgNumber( retval );
			return pnum;
		}
		catch( ArrayIndexOutOfBoundsException e )
		{    // 20090701 KSC: catch exception
			return new PtgErr( PtgErr.ERROR_VALUE );
		}
	}