I have Hex data as
Byte[] data = new Byte[2];
data[0]=FF;
data[1]=FF;
Here the binary representation of this data is as
1111 1111 1111 1111
Here i want to find the integer value from bit 0 to 11 only. (From left to right) But i am not getting how to find value with minimal complexity? Please help me.Thanks in advance.
If you want only specific bits, you can apply a logical AND with a bit mask.
In your case the bit mask is 0000 1111 1111 1111 (bits zero to and including eleven) or 0FFF.
You mention “from left to right”, so maybe instead you want 1111 1111 1111 0000 (FFF0) – bits 4 up to and including 15.