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