By combining the digits of 0 and 1, you can create 256 unique values ranging from 00000000 to 11111111.
Each bit in a byte represents a power of 2 as you can see in this chart. Note that the "Bit Column" represents a digit position couting upwards from the right end of the byte towards the left.
Bit Column | Power of 2 | Hex Value | Decimal Value |
---|---|---|---|
0 | 2⁰ | 1 | 1 |
1 | 2¹ | 2 | 2 |
2 | 2² | 4 | 4 |
3 | 2³ | 8 | 8 |
4 | 2⁴ | 10 | 16 |
5 | 2⁵ | 20 | 32 |
6 | 2⁶ | 40 | 64 |
7 | 2⁷ | 80 | 128 |
To represent, for example, a number 65, you would need a byte of 10000001, with the left-most digit being 128 and the right-most digit being 1, so 128 + 1 = 129.
Earlier I said two nibbles makes a byte. You can represent 129 in hexadecimal by 81, with the first four digits, the first nibble, of 1000 making and 8 and the last four digits, the last nibble, 0001 making a 1.
You can represent a byte with two hexadecimal nibbles instead of a decimal value since they would be easier to remember which bytes represent what characters. Most of the character sets are grouped according to a hexadecimal numbering scheme of some sort so coders would find it easier to write programs that use the bits to display the characters on the screen.
Once again, below is the bit value table. This applies to nibbles, which are bits in groups of four. Combine two of the nibbles to make a byte.
Bits | Decimal Value | Hexadecimal Value |
---|---|---|
0000 | 0 | 0 |
0001 | 1 | 1 |
0010 | 2 | 2 |
0011 | 3 | 3 |
0100 | 4 | 4 |
0101 | 5 | 5 |
0110 | 6 | 6 |
0111 | 7 | 7 |
1000 | 8 | 8 |
1001 | 9 | 9 |
1010 | 10 | A |
1011 | 11 | B |
1100 | 12 | C |
1101 | 13 | D |
1110 | 14 | E |
1111 | 15 | F |
Since bits are powers of 2, nibbles are basically powers of 16. The nibble on the left represents 16¹, or 16, and the nibble on the right represents 16⁰, or 1. Note that the "Nibble Column" represents a digit position couting upwards from the right end of the byte towards the left.
Nibble Column | Power of 16 | Hex Value | Decimal Value |
---|---|---|---|
0 | 16⁰ | 1 | 1 |
1 | 16¹ | 10 | 16 |
Here is an excerpt of the nibble value table. The actual table runs for 256 values.
Nibbles in Hexadecimal | Byte in Hexadecimal | Decimal Value |
---|---|---|
0 0 | 00 | 0 |
0 1 | 01 | 1 |
0 F | 0F | 15 |
1 0 | 10 | 16 |
2 0 | 20 | 32 |
4 0 | 40 | 64 |
6 0 | 60 | 96 |
7 F | 7F | 127 |
8 0 | 80 | 128 |
F F | FF | 255 |
© 1995-2023. davesfunstuff.com. All Rights Reserved. Reproduction of any part of this website without expressed written consent is prohibited.