Created
May 15, 2014 07:10
-
-
Save chrisvest/962a788c36344223101f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
outer:for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) { | |
// Optimise the program by checking most likely candidates for | |
// coercion conflicts first. | |
boolean foundConflict = false; | |
for (int x = 1; x < 100; x++) { | |
// scala> for (x <- 1 until 15) | |
// yield ((x / 2) ^ (-1 * (x % 2))); | |
// res21: Seq[Int] = | |
// Vector(-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7) | |
int j = i + ((x / 2) ^ (-1 * (x % 2))); | |
if (((double) i) == ((double) j)) { | |
foundConflict = true; | |
System.out.printf( | |
"Coercion conflict: i = %s, j = %s, " + | |
"double i = %f, double j = %f%n", | |
i, j, (double) i, (double) j); | |
} | |
if (x >= 2 && !foundConflict) { | |
// The two most likely conflicting candidates have been | |
// checked, and found nothing. Let's move on to the next i. | |
continue outer; | |
} | |
} | |
} | |
System.out.println("Done"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment