2.4 - Binary Numbers
Understanding binary and denary systems
Computers process all data using only two digits: 0 and 1. This system is known as binary, or base-2, because it uses powers of 2 for its place values. In contrast, the everyday number system uses ten digits (0 through 9) and is called denary, decimal, or base-10, relying on powers of 10.
Key differences between binary and denary:
- Digits used - Denary uses 0-9, while binary uses only 0 and 1.
- Base - Denary is base-10 (powers of 10), and binary is base-2 (powers of 2).
- Place values - In denary, place values from right to left are 1, 10, 100, 1000, etc. In binary, they are 1, 2, 4, 8, 16, etc.
Counting in binary
Counting in binary follows a similar pattern to denary, but each position represents a power of 2 starting from the right.
Place values in binary
The place values increase as powers of 2 from right to left:
- Rightmost: = 1
- Next: = 2
- Next: = 4
- Next: = 8
- And so on, up to higher powers like = 128 for 8-bit numbers.
Binary equivalents of denary numbers 0 to 15
| Denary | Binary |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| 10 | 1010 |
| 11 | 1011 |
| 12 | 1100 |
| 13 | 1101 |
| 14 | 1110 |
| 15 | 1111 |
These binary numbers can be extended to 8 bits by adding leading zeros, such as 0000 1111 for 15.
Key concepts in binary numbers
Binary numbers are often represented in fixed lengths, like 8 bits, to ensure consistency in computer systems.
Bits and their significance:
- Bit - The smallest unit of data in binary, representing a single 0 or 1.
- 8-bit binary - A sequence of 8 bits that can represent denary numbers from 0 to 255 (e.g., 0000 0000 to 1111 1111).
- Most significant bit (MSB) - The leftmost bit in a binary number, which has the highest place value (e.g., the 128s place in an 8-bit number).
- Least significant bit (LSB) - The rightmost bit, with the lowest place value (e.g., the 1s place).
Converting binary to denary
To convert a binary number to denary, use a table of place values and add up the values where there is a 1.
Steps for binary to denary conversion:
- Create a table with place values starting from on the right and doubling leftwards (e.g., for 8 bits: 128, 64, 32, 16, 8, 4, 2, 1).
- Write the binary digits under the corresponding place values.
- Add the place values for every column with a 1; ignore columns with 0.
Worked example - Converting binary to denary
Convert the 8-bit binary number 0101 1010 to denary.
Step 1: Set up the place value table
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
Step 2: Identify values with 1s
- 64 (from the 64s place)
- 16 (from the 16s place)
- 8 (from the 8s place)
- 2 (from the 2s place)
Step 3: Calculate the total
64 + 16 + 8 + 2 = 90
Step 4: Interpretation
The binary number 0101 1010 is equal to 90 in denary.
Converting denary to binary
Converting from denary to binary involves subtracting place values from largest to smallest, placing 1s where subtraction is possible without going negative.
Steps for denary to binary conversion:
- Set up a table with binary place values (e.g., for 8 bits: 128 down to 1).
- Start with the largest place value and subtract it from the denary number if the result is positive or zero; place a 1 in that column.
- If subtraction would give a negative result, place a 0 and move to the next value.
- Continue until the remaining value is zero, filling any unused columns with 0s.
Worked example - Converting denary to binary
Convert the denary number 93 to an 8-bit binary number.
Step 1: Set up the place value table and start subtracting
- 93 - 128 = negative, so 0 in 128s place; remaining = 93
- 93 - 64 = 29 (positive), so 1 in 64s place; remaining = 29
- 29 - 32 = negative, so 0 in 32s place; remaining = 29
- 29 - 16 = 13 (positive), so 1 in 16s place; remaining = 13
- 13 - 8 = 5 (positive), so 1 in 8s place; remaining = 5
- 5 - 4 = 1 (positive), so 1 in 4s place; remaining = 1
- 1 - 2 = negative, so 0 in 2s place; remaining = 1
- 1 - 1 = 0 (positive), so 1 in 1s place; remaining = 0
Step 2: Fill in the binary digits
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 |
Step 3: Write the binary number
0101 1101
Step 4: Interpretation
The denary number 93 is 0101 1101 in 8-bit binary.