コード例 #1
0
 int equals(ComplexByte cparm)
 {
     if (real != cparm.getrealpart())
     {
         return(0);
     }
     if (imag != cparm.getimagpart( ))
     {
         return(0);
     }
     return(1);
 }
コード例 #2
0
ファイル: NormalException.cs プロジェクト: CheneyWu/coreclr
	void add( ComplexByte cparm ) 
	{
		int rtemp, itemp;
		rtemp = real + cparm.getrealpart();
		if ( ( rtemp > 127 ) || ( rtemp < -128 ) )
			throw new ArithmeticException();
		itemp = imag + cparm.getimagpart();
		if ( ( itemp > 127 ) || ( itemp < -128 ) )
			throw new ArithmeticException();	
		real = (byte)( rtemp);
		imag = (byte)( itemp );
	}
コード例 #3
0
ファイル: NormalException.cs プロジェクト: CheneyWu/coreclr
	int equals( ComplexByte cparm )
	{
		if (real != cparm.getrealpart())
		{
			return 0;
		}
		if(imag != cparm.getimagpart( ))
		{
			return 0;
		}
		return 1;
	}
コード例 #4
0
    public static int Main(String [] args)
    {
        String s       = "Done";
        int    retVal  = 100;
        int    tryflag = 1;

        try {
            throw new UserException();
        }
        catch (ArithmeticException) {
            Console.WriteLine("AE was caught");
        }

        try {
            ComplexByte c4 = new ComplexByte(200, -200);
        }
        catch (ArgumentException) {
            tryflag = 0;              // we caught it
            Console.WriteLine("Caught Argument Exception in Test Case 8");
        }
        finally {
            if (tryflag != 0)
            {
                retVal = 8;
            }
        }

        tryflag = 1;

        try {
            ComplexByte c4 = new ComplexByte(100, -100);
            c4.add(200, -200);
        }
        catch (ArithmeticException) {
            tryflag = 0;                      // we caught it
            Console.WriteLine("Caught Arithmetic Exception in Test Case 9");
        }
        finally {
            if (tryflag != 0)
            {
                retVal = 9;
            }
        }


        Console.WriteLine(s);
        return(retVal);
    }
コード例 #5
0
    void add(ComplexByte cparm)
    {
        int rtemp, itemp;

        rtemp = real + cparm.getrealpart();
        if ((rtemp > 127) || (rtemp < -128))
        {
            throw new ArithmeticException();
        }
        itemp = imag + cparm.getimagpart();
        if ((itemp > 127) || (itemp < -128))
        {
            throw new ArithmeticException();
        }
        real = (byte)(rtemp);
        imag = (byte)(itemp);
    }
コード例 #6
0
    void multiply(ComplexByte cparm)
    {
        int rtemp, itemp;

        rtemp = (real * cparm.getrealpart( ) - imag * cparm.getimagpart( ));
        itemp = (real * cparm.getimagpart( ) + cparm.getrealpart( ) * imag);

        if ((rtemp > 127) || (rtemp < -128))
        {
            throw new ArithmeticException();
        }
        if ((itemp > 127) || (itemp < -128))
        {
            throw new ArithmeticException();
        }
        real = (byte)rtemp;
        imag = (byte)itemp;
    }
コード例 #7
0
 void assign(ComplexByte cparm)
 {
     real = cparm.getrealpart( );
     imag = cparm.getimagpart( );
 }
コード例 #8
0
 public ComplexByte(ComplexByte cparm)
 {
     this.real = cparm.getrealpart( );
     this.imag = cparm.getimagpart( );
 }
コード例 #9
0
ファイル: NormalException.cs プロジェクト: CheneyWu/coreclr
	void assign( ComplexByte cparm )
	{
		real = cparm.getrealpart( );
		imag = cparm.getimagpart( );
	}
コード例 #10
0
ファイル: NormalException.cs プロジェクト: CheneyWu/coreclr
    public static int Main( String [] args ) 
	{
		String s = "Done";
		int retVal = 100;
		int tryflag = 1;

		try {
			throw new UserException();
		}
		catch (ArithmeticException ){
			Console.WriteLine("AE was caught");	
			
		}

		try {
			ComplexByte c4 = new ComplexByte(  200, -200  );
		}
		catch ( ArgumentException ) {
			tryflag = 0;  // we caught it		
			Console.WriteLine( "Caught Argument Exception in Test Case 8" );
		}
		finally {
			if ( tryflag != 0 ) {
				retVal = 8;
			}
		}

		tryflag = 1;

		try {
				ComplexByte c4 = new ComplexByte(  100, -100  );
				c4.add( 200, -200 );
		}
		catch ( ArithmeticException ) {
				tryflag = 0;  // we caught it		
				Console.WriteLine( "Caught Arithmetic Exception in Test Case 9" );
		}
		finally {
			if ( tryflag != 0 ) {
				retVal = 9;
			}
		}
		
		
		Console.WriteLine(s);
		return retVal;		
    }  
コード例 #11
0
ファイル: NormalException.cs プロジェクト: CheneyWu/coreclr
	public ComplexByte( ComplexByte cparm )
	{
		this.real = cparm.getrealpart( );
		this.imag = cparm.getimagpart( );
	}
コード例 #12
0
ファイル: NormalException.cs プロジェクト: CheneyWu/coreclr
	void multiply( ComplexByte cparm )  
	{
		int rtemp, itemp;
	
		rtemp = (real * cparm.getrealpart( ) - imag * cparm.getimagpart( ));
		itemp = (real * cparm.getimagpart( ) + cparm.getrealpart( ) * imag);

		if ( ( rtemp > 127 ) || ( rtemp < -128 ) )
			throw new ArithmeticException();
		if ( ( itemp > 127 ) || ( itemp < -128 ) )
			throw new ArithmeticException();	
		real = (byte) rtemp;
		imag = (byte) itemp;
	}