5
103
6 bits 111110 = 32 + 16 + 8 + 4 + 2 + 0
If the 8 bits represent a signed number, the range is usually -128 to +127. This is -27 to 27-1.
To consider the difference between straight binary and BCD, the binary numbers need to be split up into 4 binary digits (bits) starting from the units. In 4 bits there are 16 possible values from 0000 to 1111 (0 to 15). In straight binary all of these possible combinations are used, thus: 4 bits can represent the decimal numbers 0-15 8 bits can represent the decimal numbers 0-255 12 bits can represent the decimal numbers 0-4095 16 bits can represent the decimal numbers 0-65535 etc In arithmetic, all combinations of bits are used, thus: 0000 1001 + 0001 = 0000 1010 In BCD or Binary Coded Decimal, only the representations of the decimal numbers 0-9 are used (that is 0000 to 1001 in binary), and the 4-bits (nybbles) are read as decimal digits, thus: 4 bits can represent the decimal digits 0-9 8 bits can represent the decimal digits 0-99 12 bits can represent the decimal digits 0-999 16 bits can represent the decimal digits 0-9999 In arithmetic, only the representations of decimal numbers are used, thus: 0000 1001 + 0001 = 0001 0000 When BCD is used each half of a byte is read directly as a decimal digit. BCD is obviously inefficient as storage (for large numbers) as each nybble is only holding 3/8 of the possible numbers, however, it is sometimes easier and quicker to work with decimal digits (for example when there is lots of display of counting numbers to do there is less binary to decimal conversion needing to be done).
5
8 bits if unsigned, 9 bits if signed
how many bits are needed to represent decimal values ranging from 0 to 12,500?
9 bits
1200
8
8
8 (assuming unsigned numbers - i.e., you don't reserve a bit for the sign).
103
Four bytes represent 32 bits. 32 bits represent 4,294,967,296 possibilities.
17 bits would allow a value up to 131071.
6 bits 111110 = 32 + 16 + 8 + 4 + 2 + 0