DE-01: Number Systems — VLSI Trainers
Digital Electronics Series · DE-01

Number Systems

Positional number systems, radix conversions between decimal/binary/octal/hex, binary addition and subtraction, signed numbers — 1’s and 2’s complement, binary multiplication and division, and floating-point representation.

🔢 Positional Number Systems

Every number system we use is a positional system — the value of a digit depends on both the digit itself and its position. The familiar decimal system has radix (base) 10 with digits 0–9. The general form for any number in any base r is:

General Positional Number Formula — Any Base r N = aₙ×rⁿ + … + a₂×r² + a₁×r¹ + a₀×r⁰ + a₋₁×r⁻¹ + … + a₋ₘ×r⁻ᵐ where r = radix/base · digits aₙ…a₋ₘ range from 0 to (r−1) · aₙ = MSD · a₋ₘ = LSD
Figure 1 — The positional number formula. Every number system — binary, octal, decimal, hexadecimal — is a special case of this formula with different values of r.
Number SystemRadix (r)Digits UsedUsed In
Binary20, 1All digital hardware — the language of logic gates
Octal80 – 7Compact representation of binary; Unix file permissions
Decimal100 – 9Human-readable I/O, BCD encoding
Hexadecimal160–9, A–FMemory addresses, register dumps, color codes

💡 Binary Number System

The binary system has radix 2 and only two digits — 0 and 1 — called bits (binary digits). Every position represents a power of 2. The decimal value of a binary number is found by multiplying each bit by its positional weight and summing.

Example 1.1 — Binary to Decimal Conversion

Convert (11011001.0101)₂ to decimal.

Integer part(1×2⁷) + (1×2⁶) + (0×2⁵) + (1×2⁴) + (1×2³) + (0×2²) + (0×2¹) + (1×2⁰) = 128+64+0+16+8+0+0+1 = 217
Fraction(0×2⁻¹) + (1×2⁻²) + (0×2⁻³) + (1×2⁻⁴) = 0 + 0.25 + 0 + 0.0625 = 0.3125
Answer: (11011001.0101)₂ = (217.3125)₁₀

A quick way to remember binary weights: starting from the right, each position doubles — 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, …

Binary Positional Weights — 8-bit Example: 10110110 1 0 1 1 0 1 1 0 2⁷=128 2⁶=64 2⁵=32 2⁴=16 2³=8 2²=4 2¹=2 2⁰=1 Value = 128+32+16+4+2 = 182 · Blue bits contribute; grey bits are 0
Figure 2 — Each bit position carries a weight equal to a power of 2. Only the ‘1’ bits contribute to the final decimal value.

8️⃣ Octal Number System

The octal system has radix 8 and digits 0–7. It is useful as a compact representation of binary — each octal digit maps exactly to 3 binary bits.

Example 1.2 — Octal to Decimal

Convert (7126.45)₈ to decimal.

Expand7×8³ + 1×8² + 2×8¹ + 6×8⁰ + 4×8⁻¹ + 5×8⁻²
Compute512 + 64 + 16 + 6 + 0.5 + 0.078125
Answer: (7126.45)₈ = (598.578125)₁₀

🔡 Hexadecimal Number System

Hexadecimal (hex) has radix 16 with digits 0–9 and A–F, where A=10, B=11, C=12, D=13, E=14, F=15. Each hex digit maps to exactly 4 binary bits (a nibble), making it the preferred human-readable format for binary data.

HexDecimalBinary (4-bit)HexDecimalBinary (4-bit)
000000881000
110001991001
220010A101010
330011B111011
440100C121100
550101D131101
660110E141110
770111F151111
Example 1.3 — Hexadecimal to Decimal

Convert (3BC7.46)₁₆ to decimal.

Expand3×16³ + 11×16² + 12×16¹ + 7×16⁰ + 4×16⁻¹ + 6×16⁻²
Compute12288 + 2816 + 192 + 7 + 0.25 + 0.0234375
Answer: (3BC7.46)₁₆ = (15303.2734375)₁₀

🔄 Decimal → Binary Conversion (Integer)

To convert an integer decimal number to binary, repeatedly divide by 2 and collect the remainders in reverse order (bottom to top). The remainders give the binary digits from LSB to MSB.

Example 1.4 — Decimal to Binary: 35 and 127

Convert 35:

÷235 ÷ 2 = 17 remainder 1 (LSB)
÷217 ÷ 2 = 8 remainder 1
÷28 ÷ 2 = 4 remainder 0
÷24 ÷ 2 = 2 remainder 0
÷22 ÷ 2 = 1 remainder 0
÷21 ÷ 2 = 0 remainder 1 (MSB)
(35)₁₀ = (100011)₂

Convert 127: Applying same repeated division → (1111111)₂ ✓ (all 7 bits = 1 → 2⁷−1 = 127)

General rule. To convert a decimal integer to base r, divide repeatedly by r and collect remainders bottom-to-top. For octal divide by 8; for hex divide by 16.

0️⃣ Fractional Decimal → Binary Conversion

For fractional decimal numbers, repeatedly multiply by 2. The integer part of each product gives the next binary digit (MSB first). Stop when the fractional part becomes 0 or the required precision is reached.

Example 1.5 — Fractional Decimal to Binary: 0.625
×20.625 × 2 = 1.25 → bit = 1 (MSB)
×20.25 × 2 = 0.50 → bit = 0
×20.50 × 2 = 1.00 → bit = 1 (LSB) — fraction = 0, stop
(0.625)₁₀ = (0.101)₂
Recurring fractions. Some decimal fractions (e.g., 0.1) do not have an exact finite binary representation. The multiplication process produces a repeating pattern. In such cases, truncate to the required number of bits and note the approximation error.

↔️ Octal ↔ Binary ↔ Hexadecimal

Because 8 = 2³ and 16 = 2⁴, conversions between binary and octal/hex require no arithmetic — just grouping of bits.

Binary ↔ Octal (groups of 3) and Binary ↔ Hex (groups of 4) OCTAL ↔ BINARY: (7126)₈ 7 1 2 6 111 001 010 110 (7126)₈ = (111 001 010 110)₂ ← each octal digit → 3 bits HEX ↔ BINARY: (3BC7)₁₆ 3 B C 7 0011 1011 1100 0111 (3BC7)₁₆ = (0011 1011 1100 0111)₂ ← each hex digit → 4 bits
Figure 3 — No arithmetic needed. Octal ↔ Binary: group binary in 3s from the radix point outward. Hex ↔ Binary: group in 4s. To go from Octal to Hex, convert via binary as the intermediate step.

Binary Addition & Subtraction

Binary addition follows four simple rules. A carry propagates left when both bits and any incoming carry total ≥ 2.

ABSumCarry
0000
0110
1010
1101
Example — Binary Addition: 1011 + 1101
Setup 1011
  +1101
─────
Carry1111  (carries above each column)
1011 + 1101 = 11000 → 11 + 13 = 24 ✓

Binary Subtraction — Borrow Method

ABDifferenceBorrow
0000
0111
1010
1100

±️ Signed Numbers — 1’s and 2’s Complement

In digital systems, negative numbers are represented using complement notation. The MSB serves as the sign bit: 0 = positive, 1 = negative.

1’s Complement

Flip every bit of the binary number. The 1’s complement of a positive number gives its negative representation. Adding a number and its 1’s complement gives all 1’s (−0 problem exists).

2’s Complement

Add 1 to the 1’s complement. This is the standard representation used in virtually all modern computers because it has a unique zero and simplifies arithmetic hardware.

Finding 2’s Complement of (01101000)₂ = +104 Step 1 — 1’s Complement (invert all bits) 01101000 → 10010111 Each 0 becomes 1, each 1 becomes 0 Step 2 — Add 1 to get 2’s Complement 10010111 + 00000001 = 10011000 This represents −104 in 8-bit 2’s complement Verification — Add original and its 2’s complement 01101000 (+104) + 10011000 (−104) = 100000000 → discard carry = 00000000 (0) ✓ The overflow carry is discarded — result is zero as expected
Figure 4 — 2’s complement of +104. The MSB of the result (10011000) is 1, confirming it represents a negative number. When added back to the original, the 9-bit result’s overflow carry is discarded, leaving zero.
Why 2’s complement dominates. Unlike sign-magnitude or 1’s complement, 2’s complement has only one zero representation, no end-around carry needed, and subtraction is performed using the same adder hardware as addition — which is why every modern CPU uses it.

🖩 Addition/Subtraction Using 2’s Complement

The key insight: A − B = A + (2’s complement of B). This means subtraction hardware is just addition hardware with the B input complemented.

OperationMethodResult valid when…
Positive + PositiveDirect binary additionNo carry out of sign bit
Positive − PositiveAdd 2’s complement of subtrahendDiscard final carry; result is correct
Negative + NegativeAdd the two 2’s complement representationsDiscard carry; both results should be negative
Overflow detectionCarry into sign bit ≠ carry out of sign bitOverflow if carries differ — result is wrong
Example — Subtract 25 from 53 using 2’s complement (8-bit)
53 in bin00110101
25 in bin00011001
1’s comp of 2511100110
2’s comp of 2511100111 (= −25)
Add00110101 + 11100111 = 1_00011100
Discard carry00011100 = 28₁₀ ✓
53 − 25 = 28 ✓

✖️ Binary Multiplication & Division

Multiplication

Binary multiplication uses the same shift-and-add algorithm as long multiplication in decimal. Since digits are only 0 or 1, each partial product is either 0 or a shifted copy of the multiplicand.

Example — Multiply (1011)₂ × (1101)₂
×bit 01011 × 1 = 1011 (no shift)
×bit 11011 × 0 = 0000 (shift 1 left)
×bit 21011 × 1 = 1011_00 (shift 2 left)
×bit 31011 × 1 = 1011_000 (shift 3 left)
Sum1011 + 0000 + 101100 + 1011000 = 10001111
(1011)₂ × (1101)₂ = (10001111)₂ = 143₁₀ · Check: 11 × 13 = 143 ✓

Division

Binary division mirrors long division in decimal. At each step, check whether the divisor fits into the current partial dividend — if yes, quotient bit is 1 and subtract; if no, quotient bit is 0 and bring down the next bit.

📐 Floating-Point Representation

Very large or very small numbers are stored in floating-point format, analogous to scientific notation. A binary number is normalised so that there is exactly one non-zero digit before the binary point:

IEEE-style Floating-Point Format (32-bit single precision) Sign 1 bit bit 31 Exponent 8 bits biased by 127 Mantissa (Significand) 23 bits — fractional part only leading 1 is implicit (normalised) Value = (−1)ˢ × 1.mantissa × 2^(exponent−127) · Range ≈ ±3.4×10³⁸
Figure 5 — IEEE 754 single-precision floating-point. The leading 1 of the normalised mantissa is implied (hidden bit), giving 24 bits of effective precision. The exponent is stored with a bias of 127 to allow both positive and negative exponents without a separate sign bit.
Normalisation. A binary number is normalised when written as 1.xxx × 2ⁿ. For example, (22)₁₀ = (10110)₂ normalises to 1.0110 × 2⁴. The stored exponent = 4 + 127 = 131 = (10000011)₂ and the stored mantissa = 01100000000000000000000 (the part after the 1.).

📋 Quick Reference

TopicRule / Formula
Decimal → Binary (integer)Divide by 2, collect remainders LSB→MSB
Decimal → Binary (fraction)Multiply by 2, collect integer parts MSB→LSB
Binary → OctalGroup bits in 3s from radix point; each group = one octal digit
Binary → HexGroup bits in 4s from radix point; each group = one hex digit
1’s ComplementInvert all bits
2’s ComplementInvert all bits then add 1
Subtraction via 2’s compA − B = A + (2’s complement of B); discard carry out
Overflow detectionCarry into MSB ≠ carry out of MSB → overflow
Binary multiplicationShift-and-add; partial product = shifted multiplicand if bit = 1, else 0
Floating point (32-bit)1 sign + 8 exponent (bias 127) + 23 mantissa bits; value = (−1)ˢ × 1.M × 2^(E−127)
Coming next — DE-02: Binary Codes — BCD, weighted codes, Gray code, Excess-3, Hamming error-correcting codes, CRC, and alphanumeric codes including ASCII.
Scroll to Top