Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 360863

Summary: Smallfloat to string conversion does not agree with javagen
Product: z_Archived Reporter: Kathy Carroll <carrollk>
Component: EDTAssignee: Kathy Carroll <carrollk>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hjiyong, jeffdouglas, jqian, mheitz, svihovec, tww
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Kathy Carroll CLA 2011-10-13 12:18:53 EDT
Use EUNIT to run the variations

package mine;


library SmallTester

	expectedStr string; 
	variation string;
	
	
	
	function runConversionFunction07(){@Test}
		variation = "float asString conversion1";
		actual float = 2.539E7;
		actualStr string = actual;
		expectedStr = "2.539E7";
		LogResult.assertStringEqual1(expectedStr, actualStr);
	end
	
	function runConversionFunction08(){@Test}
		variation = "float asString conversion2";
		actual float = -2.539e7;;
		actualStr string = actual;
		expectedStr = "-2.539E7";
		LogResult.assertStringEqual1( expectedStr, actualStr);
	end
	
	function runConversionFunction09(){@Test}
		variation = "smallFloat asString conversion1";
		actual smallFloat = 2.539E7;
		actualStr string = actual;
		expectedStr = "2.539E7";
		LogResult.assertStringEqual1( expectedStr, actualStr);
	end
	
	function runConversionFunction10(){@Test}
		variation = "smallFloat asString conversion2";
		actual smallFloat = -2.539e7;
		actualStr string = actual;
		expectedStr = "-2.539E7";
		LogResult.assertStringEqual1( expectedStr, actualStr);
	end
	
end
Comment 1 Brian Svihovec CLA 2011-11-17 11:59:52 EST
I spoke with Tim about this one as well, and we both agree that the behavior should be the default for the platform being used.  For example, in Java:

double actual = 2.539E7;
		System.out.println(actual);
		System.out.println(String.valueOf(actual));

prints:
2.539E7
2.539E7

In EDT, Java prints the same thing. 

We should write the code above in JavaScript outside of EDT, and the same behavior should occur in what we generate for JavaScript in EDT.

NOTE: If you are reading this and say to yourself, "this is going to change a lot of things", please discuss this in more detail with Tim, Brian, and Jing before making the changes.  I would rather let this one test case fail for .7 than start making fundamental changes in our generated code at this point.
Comment 2 Brian Svihovec CLA 2011-11-17 12:15:33 EST
After thinking about this more, I think we should defer this one until we have time to discuss the implications of the change I proposed.
Comment 3 Huang Ji Yong CLA 2011-12-27 04:27:34 EST
According to comment 1 by Brian, I try it in pure javascript, the string value is 2539000
the same as EGL result.
<script type="text/javascript">
var actual = 2.539e7; //also try 2.539E7
alert(actual);
alert(actual.toString());
alert(""+actual);
</script>

So I think this is not a bug but a platform difference. So route this bug to Kathy to change the test case of EUnit.
Comment 4 Brian Svihovec CLA 2012-01-11 15:42:24 EST
Matt, can you review this defect and let us know if you agree with the final decision?
Comment 5 Matt Heitz CLA 2012-01-13 16:26:18 EST
+1

I agree, because in cases like this we always defer to the target language.  

"Cases like this" are situations in which our definition of EGL allows us some leeway, and we have a choice between faster/easier/non-portable code vs. slower/complex/portable code.

The leeway I refer to is in the doc comment on EString.asString(ESmallfloat).  It says the result "may end with an exponent".  It doesn't set any conditions as to if/when the result must have an exponent.
Comment 6 Brian Svihovec CLA 2012-01-16 15:31:57 EST
I talked with Tim, and we agree with comment 5.
Comment 7 Kathy Carroll CLA 2012-02-22 15:10:58 EST
Testcase has been modified.  java and javascript produce the same result. RBD is the exception.
Comment 8 Kathy Carroll CLA 2012-02-22 15:11:22 EST
verified with 2/21 build