harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vera Petrashkova (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3025) [drlvm][jit][opt] Conversion operations return incorrect results on Jitrino OPT
Date Fri, 19 Jan 2007 09:04:29 GMT
[drlvm][jit][opt] Conversion operations return incorrect results on Jitrino OPT
-------------------------------------------------------------------------------

                 Key: HARMONY-3025
                 URL: https://issues.apache.org/jira/browse/HARMONY-3025
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
         Environment: Linux and Windows
            Reporter: Vera Petrashkova


The following test demonstrates that conversion operations return incorrect results on Jitrino
OPT
especially when Double, Float, Integer MAX_VALUEs are used in preliminary calculations.

-----------------
public class testConv {

    static double dMAX = Double.MAX_VALUE;
    static double dNEG = -1.000000E200;
    static float  fMAX = Float.MAX_VALUE;

    public static void main(String[] args) {
        testDMAX();
        testDNEG();	
        testByte(); 
        testShort(); 
        testChar(); 
    }

    public static void testDMAX() {
        System.out.println("Test: long * Double.MAX_VALUE / long");
        long constLong1 = 1000;
	long constLong2 = 10;
	long result = ((long)(constLong1*dMAX))/constLong2;
	if (result == Long.MAX_VALUE/10) {
            System.out.println("  Test passed. result: " + result + " equals " + (Long.MAX_VALUE/10));
        } else {
            System.out.println("  Test failed. result: " + result + " does not equal " + (Long.MAX_VALUE/10));
        }       
    }

    public static void testDNEG() {
        System.out.println("Test: long * -1.000000E200 / long");
	int constInt1 = 800;
	int constInt2 = 8;
	int result = ((int)(constInt1*dNEG))/constInt2;
	if (result == -268435456) {
            System.out.println("  Test passed. result: " + result + " equals " + (-268435456));
        } else {
            System.out.println("  Test failed. result: " + result + " does not equal " + (-268435456));
        }       
    }

    public static void testByte() {
        System.out.println("Test: convert Float.MAX_VALUE)/Integer.MAX_VALUE to byte");
        byte result1 = (byte)(((byte) Float.MAX_VALUE)/Integer.MAX_VALUE);
        byte result2 = (byte)(((byte) fMAX)/Integer.MAX_VALUE);
        System.out.println("result1 = " + result1);
        System.out.println("result2 = " + result2);
        if (result1 == result2) {
            System.out.println("  Test passed");
        } else {
            System.out.println("  Test failed: result != result2");
        }
    }
		
    public static void testShort() {
        System.out.println("Test: convert Double.MAX_VALUE)/Integer.MAX_VALUE to short");
        short result1 = (short)(((short) Double.MAX_VALUE)/Integer.MAX_VALUE);
        short result2 = (short)(((short) dMAX)/Integer.MAX_VALUE);
        System.out.println("result1 = " + result1);
        System.out.println("result2 = " + result2);
        if (result1 == result2) {
            System.out.println("  Test passed");
        } else {
            System.out.println("  Test failed: result != result2");
        }
    }

    public static void testChar() {
        System.out.println("Test: convert Float.MAX_VALUE)/Integer.MAX_VALUE to char");
        char result1 = (char)(((char) Float.MAX_VALUE)/Integer.MAX_VALUE);
        char result2 = (char)(((char) fMAX)/Integer.MAX_VALUE);
	System.out.println("result1 = " + (int) result1);
	System.out.println("result2 = " + (int) result2);
        if (result1 == result2) {
            System.out.println("  Test passed");
        } else {
            System.out.println("  Test failed: result != result2");
        }
    }
} 
-------------------------
On Ia32 all testcases fail:

Test: long * Double.MAX_VALUE / long
  Test failed. result: 0 does not equal 922337203685477580
Test: long * -1.000000E200 / long
  Test failed. result: 0 does not equal -268435456
Test: convert Float.MAX_VALUE)/Integer.MAX_VALUE to byte
result1 = 0
result2 = 1
  Test failed: result != result2
Test: convert Double.MAX_VALUE)/Integer.MAX_VALUE to short
result1 = 0
result2 = 1
  Test failed: result != result2
Test: convert Float.MAX_VALUE)/Integer.MAX_VALUE to char
result1 = 0
result2 = 1
  Test failed: result != result2

On EM64t output is
Test: long * Double.MAX_VALUE / long
  Test passed. result: 922337203685477580 equals 922337203685477580
Test: long * -1.000000E200 / long
  Test passed. result: -268435456 equals -268435456
Test: convert Float.MAX_VALUE)/Integer.MAX_VALUE to byte
result1 = 0
result2 = 1
  Test failed: result != result2
Test: convert Double.MAX_VALUE)/Integer.MAX_VALUE to short
result1 = 0
result2 = 1
  Test failed: result != result2
Test: convert Float.MAX_VALUE)/Integer.MAX_VALUE to char
result1 = 0
result2 = 1
  Test failed: result != result2


On interpreter and Jitrino/JET all testcase of this test pass.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message