Created
October 27, 2015 21:46
-
-
Save OutOfBrain/da7b091e73a5b620554d to your computer and use it in GitHub Desktop.
Another binary print
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
| class BinaryPrint { | |
| static void print(int number) { | |
| int mask = 1<<31; | |
| while ((number <<= 1) != 0) { | |
| System.out.print(((number & mask) != 0) ? 1 : 0); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment