Note for JAVA users

programming
Tags: #<Tag:0x00007f242f6040c8>

#1

While doing the left shift operation, make sure you do -
(1L<<i));
instead of
(1<<i));
It is necessary to attach the L symbol at the end of 1 to make sure that’s its long-datatype, else java will assume it to be a int and your answer will go out-of-range.


#2

Thanks! you save a lot of time!


#3

Really thanks it save lots of time


#4

Thanks Man. Struggled a lot to understand why the numbers are going in negative