posted 8 years ago
As an int, 129 has the following bit representation

00000000000000000000000010000001

When you cast to a byte, you only have the last 8 bits.

So you have the byte

10000001

Because the first bit is a 1, this is a negative number.

To find out what number it is the negative of, flip all the bits and add 1

You get

01111111

So the number is -127.