Please

UseCodeTags next time, that will make it a bit easier to read your code.

To get the value of the left-most bit, you need a bit mask of 1000 000 for byte, 1000 0000 0000 0000 for short, 1000 0000 0000 0000 0000 0000 0000 0000 for int and 1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 for long. The good thing is, you don't need to write them as such. You can use the bitwise operators to get those numbers:

1 << 7 (the size of byte is 8 so subtract one)

1 << 15 (the size of short is 16 so subtract one)

1 << 31 (the size of int is 32 so subtract one)

1L << 63 (the size of long is 64 so subtract one; the L is to make the result long instead of int)

Alternatively, you can use 1 << -1 for int and 1L << -1 for long. That's because the number to shift by is modulo 32 for int and modulo 64 for long.