Answer the question
In order to leave comments, you need to log in
Method for writing nibble to byte array - ideas?
There is an object represented by two id: id_a and id_b.
id_a - id one byte long.
id_b - id one nibble long.
There are two arrays: byte[4096] and byte[2048].
The first array stores byte id_a, 4096 IDs in total. It corresponds to the second array with nibbles (also 4096 nibbles) that fit in a byte array of length 2048.
Knowing the offset for id_a, we can read id_b:
public static byte Nibble4(byte[] arr, int offset){
return (byte) (offset%2 == 0 ? arr[offset/2]&0x0F : (arr[offset/2]>>4)&0x0F);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question