The three bytes are declared as bytes, result is declared as (unsigne long).
For the three bytes:0 7F F9 I get a 32761, which is OK.
But for: 0 80 17 I am getting a 4294934551.
Has anybody a idea, what's wrong? I am expecting to get a 32762 .
Explanation - Arithmetic shift - Wikipedia In computer programming, an arithmetic shift is a shift operator, sometimes known as a signed shift (though it is not restricted to signed operands). For binary numbers it is a bitwise operation that shifts all of the bits of its operand; every bit in the operand is simply moved a given number of bit positions, and the vacant bit-positions are filled in. Instead of being filled with all 0s, as in logical shift, when shifting to the right, the leftmost bit (usually the sign bit in signed integer representations) is replicated to fill in all the vacant positions (this is a kind of sign extension).