If you are using Java 7 or higher, you can specify binary constants by prepending "0b" to your value, e.g.:
long value = 0b000100110011010001010111011110011001101110111100110111111110001L;
If that language feature is not available to you, you can use decimal, octal, or hexadecimal notation, however. If you're just declaring constants, you can use an online tool such as http://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html, or perhaps your favorite calculator, to convert to a radix that Java recognizes.
For example:
long value = 691913582662545393L;
Or:
long value = 0x99A2BBCCDDE6FF1L;
You may want to clarify by describing what that value means in a comment:
// binary: 000100110011010001010111011110011001101110111100110111111110001
long value = 0x99A2BBCCDDE6FF1L;
As you may have noticed from the above examples, you will need to use a long
and add the L
suffix to your constant. In Java, int
is 32-bit and long
is 64-bit. The L
suffix specifies a long
literal, without it, it is an int
and the value would be too large.
P.S. Integer literals starting with "0" (but not "0x" or "0b") are interpreted as octal. The constant you originally attempted to specify was interpreted as a very large octal number.