protected static Ptg calcAverage( Ptg[] operands )
	{
		Vector vect = new Vector();

		for( Ptg operand : operands )
		{
			Ptg[] pthings = operand.getComponents(); // optimized -- do it once!! -jm
			if( pthings != null )
			{
				for( Ptg pthing : pthings )
				{
					vect.add( pthing );
				}
			}
			else
			{
				Ptg p = operand;
				vect.add( p );
			}
		}
		int count = 0;
//        double total = 0;
		BigDecimal bd = new BigDecimal( 0 );
		for( int i = 0; i < vect.size(); i++ )
		{
			Ptg p = (Ptg) vect.elementAt( i );
			try
			{
				if( p.isBlank() )
				{
					continue;
				}
				Object ov = p.getValue();
				if( ov != null )
				{
//                    total += Double.parseDouble(String.valueOf(ov));
					bd = bd.add( new BigDecimal( Double.parseDouble( String.valueOf( ov ) ) ) );
					count++;
				}
			}
			catch( NumberFormatException e )
			{
			}
			;
		}
		bd = bd.setScale( 15, java.math.RoundingMode.HALF_UP );
		double total = bd.doubleValue();
		if( count == 0 )
		{
			return new PtgErr( PtgErr.ERROR_DIV_ZERO );
		}
		double result = total / count;
		PtgNumber pnum = new PtgNumber( result );
		return pnum;
	}