SME
Digital Logic Design
Number systems and Boolean algebra
Use this for “Write 45 in binary and hex, and −45 in 8-bit two’s complement.”
Chart
45 = 32 + 8 + 4 + 1: 101101₂, each column 2 times the one to its right.
By repeated ÷ 2: 45 → 22 r 1 → 11 r 0 → 5 r 1 → 2 r 1 → 1 r 0 → 0 r 1; the remainders read from the last are 101101.
In hex, the bits in fours: 0010 1101 = 2D₁₆. −45 in 8 bits: invert 0010 1101 to 1101 0010, add 1: 1101 0011 = D3₁₆, which is 2⁸ − 45 = 211 read unsigned.
This is an example. Type your own values to start a new problem.
N
=
N₂
=
N₁₆
T
=
2
−
N
Formulas
N₂
=
N
0,010 1,101₂ = 45
N₁₆
=
N
0x2D = 45
T
=
2
n
−
N
1,101
0,011₂
=
2
8
−
45
Assumptions
•
N is a whole number; its binary digits are the remainders of repeated ÷ 2, read from the last.
•
Hex groups the bits in fours from the right; each group is one hex digit (0–9, then A–F).
•
In n bits, −N is stored as 2ⁿ − N: invert every bit, then add 1.
•
The page needs N < 2ⁿ⁻¹, so that both N and −N fit in n signed bits.
Step-by-step
WE KNOW
N = 45, n = 8
FIND
binary (N₂), hexadecimal (N₁₆), pattern of −N (T)
Step 1 · Find binary (N₂)
Use N₂ = N
Divide by 2 again and again; the remainders, read from the last, are the bits.
N₂
=
45
45 ÷ 2 = 22 remainder 1
22 ÷ 2 = 11 remainder 0
11 ÷ 2 = 5 remainder 1
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
45 = 101,101₂
N₂
=
0010
1101₂
Step 2 · Find hexadecimal (N₁₆)
Use N₁₆ = N
Group the bits in fours from the right; each group of four is one hex digit.
N₁₆
=
45
0,010₂ = 2; 1,101₂ = 13 = D₁₆
0,010 1,101₂ = 2D₁₆
N₁₆
=
0x2D
Step 3 · Find pattern of −N (T)
Use T = 2ⁿ − N
Invert
every
bit
of
N
(that
gives
2ⁿ
−
1
−
N
),
then
add
1.
T
=
2
8
−
45
45 = 00,101,101₂
Invert every bit: 11,010,010₂
Add 1: 11,010,010₂ + 1 = 11,010,011₂ = D3₁₆
T
=
1101
0011₂
Check
Put the numbers back in. Both sides should match.
0,010 1,101₂ = 45 ✓
0x2D = 45 ✓
1,101
0,011₂
=
2
8
−
45
✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.
More problem types
Signed and unsigned ranges, overflow
Use this for “What range do 8 bits hold, signed and unsigned? What does 100 + 50 give in 8-bit signed?”
Binary-coded decimal (BCD)
Use this for “Write 59 in BCD. How many bits does it take, and how many in plain binary?”
Which Boolean law?
Use this for “Which law turns A + AB into A?” or “Which law gives (AB)′ = A′ + B′?”