Monday, April 30, 2012

Java Bit Operation on Long - Removing some bits

I have a long number. Now, what I want to do is the following:



long l = "001000......10001100000" (bits representation)


I need to remove the 3rd and 4th bits of it (i.e. 10) from the left and convert the remaining 62 bits to long



long newl = "0000......10001100000" (bits representation)


Can anybody help me do this efficiently in Java ?





No comments:

Post a Comment