Here is my problem:
I have a binary value
101001
and a mask
011100
I would like to compare them and get the result as an integer. In this case that would give:
1 **010** 01
0 **111** 00
= 010 => 2
My first idea consists of dealing with a character array. But I would like to know if there is a better way to achieve this aim in Java?
I just improved the algorithm to be able to have mask where one bits can be splitted such as:
Here is my function to get a value from a mask and a masked value
Here is my function to store a value in a variable thanks to a bitmask, it returns the old variable with the value stored inside.
I had to use BigInteger because of the shift operator that can not shift more than 32bits left in Java.