Quote:
1) I din't understand why always "and" operation is done only with 0xF.
Such operation masks out (discards) the
4
most significant bits of the byte, because
0xF
is
00001111
in binary representation. (e.g.
10101001 & 00001111 = 00001001
).
Quote:
2) In tohexString(), why ">>" operation with 4 is done?
This 'moves the right nibble to the left', that is the
4
most significant bits of the byte replace the
4
least significant ones (the right shift operator
>>
moves bits to the right). Hence, for instance,
0xAB
becomes
0x0A
.