Skip to content

Instantly share code, notes, and snippets.

@rbe
Created August 25, 2012 11:49
Show Gist options
  • Select an option

  • Save rbe/3464337 to your computer and use it in GitHub Desktop.

Select an option

Save rbe/3464337 to your computer and use it in GitHub Desktop.
Tests with bitwise operator
public class BitTest {
public static void main(String[] args) {
// Der Ausdruck (3 | 6 | 5 | 7 | 32) einzeln aufgelöst:
// (3 | 6) -> 7
System.out.println("( 3 | 6) == 7, ist " + ( 3 | 6));
// (7 | 5) -> 7
System.out.println("( 7 | 5) == 7, ist " + (7 | 5));
// (7 | 7) -> 7
System.out.println("( 7 | 7) == 7, ist " + (7 | 7));
// (32 | 7) -> 7
System.out.println("(32 | 7) == 7, ist " + (32 | 7));
// Incompatible mask: das Ergebnis ist immer falsch...
System.out.println("12 == (3 | 6 | 5 | 7 | 32) ? " + (12 == (3 | 6 | 5 | 7 | 32)));
System.out.println("12 == 39 ? " + (12 == 39));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment