⌚ September 5, 2014
Each binary digit is called a bit. In the number 11000000b, each 1 is a bit, and each 0 is a bit. The number of bits present is what is referred to when we say things like “8-bit,” “16-bit,” or “64-bit.”
A bit is a binary digit that represents a value. This works well for computers and digital devices because the bits 0 and 1 can represent the states on and off, which corresponds to the on or off flow of electrical current through the computer’s hardware.
0 = Off, False, 0 Volts 1 = On, True, +Volts
By combining these on and off bits according to the binary place value system, a wide range of values and logic states can be expressed.
Can there be any value between on and off? Or 1 and 0? No. A digital world is “all or nothing.” There are no in-between states. Otherwise, that would be analog, and computers must first convert real-world analog values into digital binary values before they can use them.
Bits are typically grouped together into fixed-sized chunks for easier recognition and for alignment purposes. Four bits form a nibble (sometimes spelled as nybble, but this is uncommon today), two nibbles form an 8-bit byte, two bytes form a 16-bit word, two words form a 32-bit double word (sometimes abbreviated to dword), and two double words form a 64-bit quad word.
Usage of the term “word” can vary according to processor documentation and context. Sometimes, a word refers to a 32-bit value and a double word refers to a 64-bit value.
Bits Example ---------------------------------------------- 1 bit 0 or 1 4 nibble 0101 8 byte 11000000 16 word 00000000 11000000 32 double word (sometimes word) 64 quad word (sometimes double word)
Bytes are usually always arranged into 8-bit groupings regardless of their values. Spaces separate multiple bytes.
The grouping of two bytes
is more common than 0000000011000000 because groupings make it easier to identify the place values and determine the number of bits. Sometimes, bits are grouped into nibbles for easier identification and for easier conversion into hexadecimal.
0000 0000 0000 1100 0000 = 0x 0 0 0 C 0 = 0x000C0
Zeros located to the left of the leftmost non-zero digit are called leading zeros, and they have no value. They only serve as padding to fill up space to complete a grouping for readability.
Identical grouping occurs with a base 10 number system. In decimal, digits are usually grouped into chunks of three digits for readability, and each group is separated with a comma. Leading zeros are typically omitted in the leftmost group, so we write
Binary usually includes leading zeros to fill out a byte of eight bits, a process known as padding. 11000 (base 2) would be written as 00011000 with three leading zeros as padding to fill the byte.
Both 11000 and 00011000 express the same value of 24 (base 10), but computers like to group bits into bytes by padding the more significant place values with zeros. Of course, there are situations, such as compression algorithms, that discard unnecessary or repetitive bits, but the typical practice is to write down a full byte for easier recognition.
Also note that binary does not use commas to separate groups of bits.
The leftmost bit of any number of digits is called the most significant bit (MSB), and the rightmost bit in the ones place is called the least significant bit (LSB).
8-bit 11000000 ^ ^ MSB LSB
16-bit 00001111 11000001 ^ ^ MSB LSB
24-bit 10101010 11110000 00001111 ^ ^ MSB LSB
The place value of the most significant bit varies according to the number of bytes, while the least significant bit is fixed in the ones place. As shown in Lesson 2, the value a bit represents depends upon its location in the place value chart.
Let’s practice formatting and answering a few random questions regarding bits and bytes.
- Format to eight bits: 11b
- Format 110011101010000011110010101111 into bytes for readability
- How many bits make a byte?
- How many unique values are possible with 24 bits?
- Separate 111100001010001111011011 into nibbles.
- Convert the answer of problem #5 into hexadecimal. Express in four different base notations.
- 00000011 (Pad with leading zeros to eight bits immediately before the right-most significant bit. )
- 00110011 10101000 00111100 10101111 (Start from the LSB and place a space between every eight bits. Pad with leading zeros.)
- 16,777,216 unique values. 16,777,215 is the highest actual value that can be represented because we always start counting from zero.
- 1111 0000 1010 0011 1101 1011
0xF0A3DB (Lowercase is also valid)
F0A3DBh (For situations like f0a3dbh, it is best to use 0x instead to avoid the "bh" confusion)
F0A3DB (base 16)