Think in decimal second. If you have only 2 digits for a number, this means that you can store from 00 to 99 in them. If you have 4 digits, this range becomes 0000 to 9999 .
The binary number is similar to the decimal, except for the digits there can only be 0 and 1 instead of 0 , 1 , 2 , 3 , ..., 9 .
If you have a number like this:
01011101
It:
0*128 + 1*64 + 0*32 + 1*16 + 1*8 + 1*4 + 0*2 + 1*1 = 93
So, as you can see, you can store larger values ​​than 9 in one byte. In an 8-bit unsigned number, you can store values ​​from 00000000 to 11111111 , which is equal to 255 in decimal form.
In a 2-byte number, this range becomes from 00000000 00000000 to 11111111 11111111 , which is 65535.
In your statement, “it takes 8 bits to store the binary representation of a number” - this is how to say “it takes 8 digits to store the decimal representation of a number,” which is incorrect. For example, the number 12345678901234567890 has more than 8 digits. Similarly, you cannot put all numbers in 8 bits, but only 256 of them. So you get 2-byte ( short ), 4-byte ( int ) and 8-byte ( long long ) numbers. In truth, if you need an even larger range of numbers, you will need to use a library.
As long as we are talking about negative numbers, on a computer with an add-on, it's just an agreement to use the higher half of the range as negative values. This means that numbers with 1 on the left side are considered negative.
However, these digits are congruent modulo 256 (modulo 2^n if n bits) to their positive value, because the number does offer, for example, the number 11111111 is 255 if unsigned, and -1 if they match congruent modulo 256.