How do you update an array within a struct array using a function

My interpretation of that result is that the declaration "char" is by default treated as "signed char", so 255 is interpreted as -1, and the sign bit is propagated, before the shift is applied to the resulting int.

The result of shifting left 7 is equivalent to multiplying (-1) by 128, so the result -128 is correct. But not what I expected!

So it is important to make sure variables are declared as unsigned.

1 Like