Your data type is int
which is represented as 2-bytes type. 2 bytes
means 2 x 8 = 16
bits in it's binary representation. Also, your sample data type is signed - and that means highest bit will be used as sign (0
for positives, 1
for negatives).
From math it's known that with binary values you can hold 2^n
unique values, i.e. for your 16-1
bits that will be 15 free bits. So that will be -(2^n) .. 2^n-1
range, where n=15
. When you'll calculate -(2^15)
and 2^15 - 1
you'll get your -32768
and 32767
. That's it.