Created
August 25, 2012 11:49
-
-
Save rbe/3464337 to your computer and use it in GitHub Desktop.
Tests with bitwise operator
This file contains hidden or 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 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