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

Bug 363867

Summary: Javascript is rounding rather than truncating when converting float to decimal
Product: z_Archived Reporter: broy2
Component: EDTAssignee: Project Inbox <edt.javascriptgen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: carrollk, jqian
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description broy2 CLA 2011-11-15 16:22:02 EST
Javascript is rounding when converting float to decimal.  
It should be truncating.

Use EUnit to run:

library truncate
	myFloat float;
	myDecimal decimal(12,6);
	function functionName() {@Test}	
		myFloat = 1.5663225538310885;
		myDecimal = myFloat;
		LogResult.assertDecimalEqual1(1.566322, myDecimal);
	end	
end

Runs OK in Java.  myDecimal = 1.566322
Gets failure in Javascript.  myDecimal = 1.566323

See 362834.
Comment 1 broy2 CLA 2011-11-15 16:25:21 EST
This causes the mathLib functions to fail running api.systemTypes in EUnit.
Comment 2 Jing Qian CLA 2011-11-21 20:13:53 EST
verified on 201111210901's build, it's successful for both java and javascript
Comment 3 Jing Qian CLA 2011-11-21 20:17:08 EST
Brenda, if this is not in eunit.test project in cvs, please add to it, so it can be used everytime we run eunit tests.
Comment 4 broy2 CLA 2011-11-22 15:52:25 EST
Done.