DIGITAL SYSTEMS
FUNDAMENTALS

BINARY • HEXADECIMAL • LOGIC

PLAYER 1 START

BINARY NUMBER SYSTEM

binary is the language of computers. every piece of data, from your favorite game to this webpage, is ultimately represented as a sequence of 1s and 0s.

WHY BINARY?

computers use binary because transistors (the building blocks of processors) have two states: ON (1) and OFF (0). it's like a light switch - either on or off, true or false, 1 or 0.

BINARY PLACE VALUES

just like decimal uses powers of 10, binary uses powers of 2:

Position: 7 6 5 4 3 2 1 0 Power: 2⁷ 2⁶ 2⁵ 2⁴ 2³ 2² 2¹ 2⁰ Value: 128 64 32 16 8 4 2 1 Example: 1010 1101 ↓↓↓↓ ↓↓↓↓ 128 + 32 + 8 + 4 + 1 = 173
EXAMPLE: CONVERT 10 0110 1101 TO DECIMAL
1 0 0 1 1 0 1 1 0 1 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 512 + 0 + 0 +128 + 64 + 0 + 16 + 8 + 0 + 1 = 512 + 128 + 64 + 16 + 8 + 1 = 729

PRO TIP: only add the place values where there's a 1. ignore positions with 0.

NUMBER SYSTEM CONVERSIONS

DECIMAL TO BINARY

to convert from decimal to binary, repeatedly divide by 2 and track the remainders:

EXAMPLE: CONVERT 73 TO 12-BIT BINARY
73 ÷ 2 = 36 remainder 1 ← LSB (least significant bit) 36 ÷ 2 = 18 remainder 0 18 ÷ 2 = 9 remainder 0 9 ÷ 2 = 4 remainder 1 4 ÷ 2 = 2 remainder 0 2 ÷ 2 = 1 remainder 0 1 ÷ 2 = 0 remainder 1 ← MSB (most significant bit) Read from bottom to top: 1001001 Pad to 12 bits: 0000 0100 1001
EXAMPLE: CONVERT 127 TO 12-BIT BINARY
127 ÷ 2 = 63 remainder 1 63 ÷ 2 = 31 remainder 1 31 ÷ 2 = 15 remainder 1 15 ÷ 2 = 7 remainder 1 7 ÷ 2 = 3 remainder 1 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1 Result: 1111111 Pad to 12 bits: 0000 0111 1111

BINARY TO DECIMAL

0000 1111 0000

= 128 + 64 + 32 + 16 = 240

1100 1100 1100

= 2048 + 1024 + 128 + 64 + 8 + 4 = 3276

UNSIGNED BINARY ARITHMETIC

unsigned binary numbers represent only positive values. the range for n bits is 0 to 2ⁿ - 1.

6-BIT UNSIGNED RANGE

with 6 bits, you can represent: 0 to 63 (2⁶ - 1 = 64 - 1 = 63)

BINARY ADDITION

binary addition works just like decimal, but with carries at 2 instead of 10:

Rules: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 (0 with carry of 1)
EXAMPLE: 000011 + 001100 (3 + 12)
000011 (3) + 001100 (12) ------ 001111 (15) NO OVERFLOW - result fits in 6 bits
EXAMPLE: 010100 + 101101 (20 + 45)
1111 (carries) 010100 (20) + 101101 (45) ------ 1000001 (65) OVERFLOW! - result needs 7 bits In 6-bit storage: 000001 (only keeps rightmost 6 bits)

OVERFLOW DETECTION: overflow occurs when the result exceeds the maximum value that can be stored. for 6-bit unsigned, any result > 63 causes overflow. look for a carry out of the leftmost bit.

SIGNED BINARY (TWO'S COMPLEMENT)

signed binary uses two's complement representation to handle both positive and negative numbers. the leftmost bit is the sign bit: 0 = positive, 1 = negative.

6-BIT SIGNED RANGE

-32 to +31 (from -2⁵ to 2⁵ - 1)

positive: 000000 to 011111 (0 to 31)

negative: 100000 to 111111 (-32 to -1)

CONVERTING TO TWO'S COMPLEMENT

to represent a negative number:

1. Start with positive binary representation 2. Invert all bits (0→1, 1→0) 3. Add 1
EXAMPLE: STORE +15 IN 6-BIT SIGNED
15 in binary: 001111 Positive number: just use binary representation Result: 001111
EXAMPLE: STORE -15 IN 6-BIT SIGNED
Step 1: +15 = 001111 Step 2: Invert = 110000 Step 3: Add 1 = 110001 Result: 110001 represents -15

CONVERTING FROM TWO'S COMPLEMENT

EXAMPLE: CONVERT 011111 TO DECIMAL
Starts with 0 → positive 011111 = 16 + 8 + 4 + 2 + 1 = 31 Result: +31
EXAMPLE: CONVERT 111001 TO DECIMAL
Starts with 1 → negative Step 1: Invert bits: 000110 Step 2: Add 1: 000111 = 7 Result: -7

SIGNED ARITHMETIC

EXAMPLE: 110101 + 001111
110101 = -11 (negative, so convert: invert→001010, add 1→001011 = 11) 001111 = +15 110101 (-11) + 001111 (+15) ------ 000100 (+4) Result: +4, NO OVERFLOW

SIGNED OVERFLOW: overflow in signed arithmetic occurs when:

• adding two positive numbers gives a negative result

• adding two negative numbers gives a positive result

• different signs CANNOT cause overflow

HEXADECIMAL NUMBER SYSTEM

hexadecimal (base 16) is a compact way to represent binary. each hex digit represents exactly 4 binary bits.

HEX DECIMAL BINARY 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111

BINARY TO HEX

EXAMPLE: CONVERT 10110100000101₂ TO HEX
Step 1: Group into sets of 4 bits (from right) 0010 1101 0000 0101 Step 2: Convert each group 0010 = 2 1101 = D 0000 = 0 0101 = 5 Result: 2D05

DECIMAL TO HEX

EXAMPLE: CONVERT 791₁₀ TO HEX
791 ÷ 16 = 49 remainder 7 49 ÷ 16 = 3 remainder 1 3 ÷ 16 = 0 remainder 3 Read from bottom up: 317₁₆

HEX TO DECIMAL

EXAMPLE: CONVERT 3FF₁₆ TO DECIMAL
3FF₁₆ = (3 × 16²) + (15 × 16¹) + (15 × 16⁰) = (3 × 256) + (15 × 16) + (15 × 1) = 768 + 240 + 15 = 1023

WHY USE HEX? hex is much more compact than binary. the 16-bit binary number 1111111111111111 is just FFFF in hex!

TRUTH TABLES & DIGITAL LOGIC

truth tables enumerate all possible input combinations and their corresponding outputs. they're fundamental to understanding digital circuits and logic design.

BASIC CONCEPT

TRUTH TABLE RULES

• n inputs produce 2ⁿ rows

• every row must have a defined output (0 or 1)

• systematically list all binary combinations

• outputs determined by logical conditions

EXAMPLE PROBLEM 1: COMPARISON LOGIC

specification: four inputs (a,b,c,d). first two (a,b) represent a number 1-3. second two (c,d) represent another number 1-3. output y=1 if first > second OR second = first + 2.

ENCODING SCHEME
ab or cd: 00 = invalid (0 not used) 01 = 1 10 = 2 11 = 3
a b c d first second condition y
0000--invalid0
0001-1invalid0
0010-2invalid0
0011-3invalid0
01001-invalid0
0101111 = 10
0110121 < 20
0111133 = 1+21
10002-invalid0
1001212 > 11
1010222 = 20
1011232 < 30
11003-invalid0
1101313 > 11
1110323 > 21
1111333 = 30

EXAMPLE PROBLEM 2: PROXIMITY CHECK

specification: four inputs (a,b,c,d). first two represent 0-2, second two represent 0-2 (3 not used). output y=1 if numbers don't differ by more than 1.

ENCODING SCHEME
ab or cd: 00 = 0 01 = 1 10 = 2 11 = invalid (3 not used)
a b c d first second |diff| y
00000001
00010111
00100220
00110--0
01001011
01011101
01101211
01111--0
10002020
10012111
10102201
10112--0
1100-0-0
1101-1-0
1110-2-0
1111---0

TRUTH TABLE STRATEGY:

1. understand the input encoding

2. list all 2ⁿ combinations systematically

3. decode inputs to actual values

4. apply logical conditions

5. assign output based on conditions

6. mark invalid/unused combinations

INTERACTIVE CALCULATORS

BINARY TO DECIMAL CONVERTER

DECIMAL TO BINARY CONVERTER

HEX CONVERTER

TWO'S COMPLEMENT CONVERTER

BINARY ADDER (6-BIT UNSIGNED)