Suppose code is given like this:
pattern_mask[pattern[i]] &= ~(1UL << i);
What kind of type is this in Java? How do I implement this in Java?
Suppose code is given like this:
pattern_mask[pattern[i]] &= ~(1UL << i);
What kind of type is this in Java? How do I implement this in Java?
Java does not have unsigned long
, but 1L
is a 64-bit signed long
literal.
long
, from -9223372036854775808
to 9223372036854775807
, inclusive long
if it is suffixed with an ASCII letter L
or l
(ell); otherwise it is of type int
. The suffix L
is preferred, because the letter l
(ell) is often hard to distinguish from the digit 1
(one).The shift count is masked: only lower 5-bits for int
shift, and only lower 6-bits for long
shift.
The following snippet shows how due to this, shifting on 1
is different from shifting on 1L
.
System.out.println(1 << 1); // prints "2"
System.out.println(1 << 33); // prints "2"
System.out.println(1L << 33); // prints "8589934592"
System.out.println(1L << 65); // prints "2"