Worksheet for bits

Use the worksheet below to help understand how bits are used to represent analog values.

Click on the "Change" button below each bit to changes its value. The totals for each Byte, and the total for the entire Word will be listed below.

HI Byte
LO Byte
bit7
bit6
bit5
bit4
bit3
bit2
bit1
bit0
bit7
bit6
bit5
bit4
bit3
bit2
bit1
bit0
128
64
32
16
8
4
2
1
128
64
32
16
8
4
2
1
Word
bit15
bit14
bit13
bit12
bit11
bit10
bit9
bit8
bit7
bit6
bit5
bit4
bit3
bit2
bit1
bit0
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1
Change
Change
Change
Change
Change
Change
Change
Change
Change
Change
Change
Change
Change
Change
Change
Change
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

The current Word total is 0

The HI Byte total is 0, and the LO Byte total is 0


Hit F5 on your keyboard to reset this page

HI Byte and LO Byte Values

One thing you will notice is that the HI Byte total does not seem to equal what it should. For instance, clear the worksheet by hitting F5 on your keyboard, or right-click and select either Refresh or Reload. Now set only bit8. The value of the Word is now 256, as you would expect. But the published value of the HI Byte is listed as "1".

This is another case of the way things really are, versus how they are reported. In reality, the true value of bit8 is 1. After all, it is really bit0 of the respective Byte. However, when we format a Byte to be the HI Byte of Word, bit8 gets counted as 256.

When you see the native LO Byte values and HI Byte values, it is important to understand that they are not simply added together. The formula to combine the native value of two Bytes into a Word is as follows:

Total value = (HI Byte x 256) + LO Byte

In the formual above, 256 is used as a multiplier on the HI Byte values. Notice the when you relate LO Byte values to their respective position in the HI Byte, the HI Byte value is the LO Byte value multiplied by 256.

bit 8 = bit0 x 256 = 1 x 256 = 256
bit 9 = bit1 x 256 = 2 x 256 = 512
bit 10 = bit2 x 256 = 4 x 256 = 1024
bit 11 = bit3 x 256 = 8 x 256 = 2048
bit 12 = bit3 x 256 = 16 x 256 = 4096
bit 13 = bit3 x 256 = 32 x 256 = 8192
bit 14 = bit3 x 256 = 64 x 256 = 16384
bit 15 = bit3 x 256 = 128 x 256 = 32768

Thus, the native sum of all the set HI Byte bits can simply be multipled by 256 to determine its formatted value.

HI Byte = bit8 + bit9 + bit10 + bit11 + bit12 + bit13 + bit14 + bit15
Total value = (HI Byte x 256) + LO Byte