The code is strange and does unnecessary things.
The shift operation ( <<
operator) shifts the bits to the left. Since the position determines the number represented, as in the decimal, each bite shifted to the left multiplies by 2 (the base of the torque) the existing value. in this case each pass by the loop will produce 1, 2, 4, 8, etc.
The result will be computed with the variable Hex
doing a and operation ( operador &
). The and works similarly to the multiplication, that is, each bit that one operand is calculated with the corresponding bite of the other operand. The result will be 1 whenever both are 1 and 0 when there is no such match.
The final result being a value other than zero executes if
, since in C this is considered to be true. If the result is 0, it executes else
.
Learn more here . The language is different but the operation is the same.