[Sablevm-bugs] [ sablevm-Bugs-753040 ] f2i with large integers
Brought to you by:
egagnon
From: SourceForge.net <no...@so...> - 2003-06-12 22:12:22
|
Bugs item #753040, was opened at 2003-06-11 22:58 Message generated for change (Comment added) made by davidbelanger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105523&aid=753040&group_id=5523 Category: None Group: None >Status: Closed Resolution: None Priority: 5 Submitted By: David Bélanger (davidbelanger) Assigned to: Nobody/Anonymous (nobody) Summary: f2i with large integers Initial Comment: Converting a float that has a value larger than the largest int to an int does not always give the largest int as specified in the specification. public class BugF2I { public static int f2i(float v) { return (int) v; } public static void main(String[] args) { System.out.println(Integer.MAX_VALUE); System.out.println(f2i(Integer.MAX_VALUE + 1.0f)); System.out.println((int) 7777779123.32f); System.out.println(f2i(7777779123.32f)); } } Note: Compiled with jikes on ppc and with javac on x86. jikes / sablevm / ppc 2147483647 2147483647 -812155392 2147483647 jikes / sablevm / x86 2147483647 -2147483648 -812155392 -2147483648 jikes / java / x86 2147483647 2147483647 -812155392 2147483647 javac / java / x86 2147483647 2147483647 2147483647 2147483647 javac / sablevm / x86 2147483647 -2147483648 2147483647 -2147483648 javac / sablevm / ppc 2147483647 2147483647 2147483647 2147483647 David ---------------------------------------------------------------------- >Comment By: David Bélanger (davidbelanger) Date: 2003-06-12 18:12 Message: Logged In: YES user_id=694080 Hi, I upgrade jikes to 1.18 (there was some other bug in 1.15) and it fixed also this problem on jikes / sablevm / ppc. It may be a jikes 1.15 bug, I tried again with javac / sablevm / x86 (though on a different machine) and I got the right result this time. To summarize, jikes 1.15 appears to have problems evaluating constant expression with floating points at compile time (constant folding) that were fixed in later versions. David ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105523&aid=753040&group_id=5523 |