protected static Ptg calcBin2Oct( Ptg[] operands )
	{
		if( operands.length < 1 )
		{
			return new PtgErr( PtgErr.ERROR_NULL );
		}
		debugOperands( operands, "Bin2Oct" );
		String bString = operands[0].getString().trim();
		int places = 0;
		if( operands.length > 1 )
		{
			places = operands[1].getIntVal();
		}

		// 10 bits at most
		if( bString.length() > 10 )
		{
			return new PtgErr( PtgErr.ERROR_NUM );
		}
		// must det. manually if binary string is negative because parseInt does not
		// handle two's complement input!!!
		boolean bIsNegative = ((bString.length() == 10) && bString.substring( 0, 1 ).equalsIgnoreCase( "1" ));

		int dec;
		String oString;
		try
		{
			dec = Integer.parseInt( bString, 2 );
			if( bIsNegative )
			{
				dec -= 1024;        // 2^10 (= signed 11 bits)
			}
			oString = Integer.toOctalString( dec );
		}
		catch( Exception e )
		{
			return new PtgErr( PtgErr.ERROR_NUM );
		}
		if( dec < 0 )
		{    // truncate to 10 digits automatically (should already be two's complement)
			oString = oString.substring( Math.max( oString.length() - 10, 0 ) );
		}
		else if( places > 0 )
		{
			if( oString.length() > places )
			{
				return new PtgErr( PtgErr.ERROR_NUM );
			}
			oString = ("0000000000" + oString);    // maximum= 10 bits
			oString = oString.substring( oString.length() - places );
		}
		PtgStr pstr = new PtgStr( oString );
		log.debug( "Result from BIN2OCT= " + pstr.getString() );
		return pstr;
	}