Created
July 29, 2011 07:55
-
-
Save prisoner/1113405 to your computer and use it in GitHub Desktop.
Binary Literals in Java7
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
// An 8-bit 'byte' value: | |
byte aByte = (byte)0b00100001; | |
// A 16-bit 'short' value: | |
short aShort = (short)0b1010000101000101; | |
// Some 32-bit 'int' values: | |
int anInt1 = 0b10100001010001011010000101000101; | |
int anInt2 = 0b101; | |
int anInt3 = 0B101; // The B can be upper or lower case. | |
// A 64-bit 'long' value. Note the "L" suffix: | |
long aLong = 0b1010000101000101101000010100010110100001010001011010000101000101L; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment