|
" (11111110) and add 1 (11111111). This can either be interpreted as 255 or -1." Only in PBASIC
Rbayer, notice "Sorry, my question was for C++ (or binary standard)," "how signs are stored in binary."
Hence, a 16 bit integer = 32767 through -32768.
or an unsigned short int which maxes 65535 (16 bits)
which leads me to believe that there is an actual extra bit for signs when compiling in c++.
nevermind, trying to explain my question I figured it out.
00000000 00000000
^ the 32768 (16th bit (n^(16-1))) or the last bit is used for signs.
11111111 11111111 = 65535
65535 + 1 = 00000000 00000000
in signed ints,
11111111 11111111 = -32768
01111111 11111111 = 32767
All of them off counts as the number 0, I think the last one signifies negative and has the value of 1.
ex: 10000000 00000000 = -1, considering 0 is never negative. That's why you get the -32768 instead of -32767
I think this makes sense, correct me if im wrong.
v = (n^(n))-1 -> max unsigned bit integer
range: 0 to v
v = (n^(n-1))-1 -> max signed integer
range: -v+1 to v
__________________
R
|