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:
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 System
Radix (r)
Digits Used
Used In
Binary
2
0, 1
All digital hardware — the language of logic gates
Octal
8
0 – 7
Compact representation of binary; Unix file permissions
Decimal
10
0 – 9
Human-readable I/O, BCD encoding
Hexadecimal
16
0–9, A–F
Memory 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.
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, …
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.
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.
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.
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.
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.
A
B
Sum
Carry
0
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1
Example — Binary Addition: 1011 + 1101
Setup 1011 +1101 ─────
Carry1111 (carries above each column)
1011 + 1101 = 11000 → 11 + 13 = 24 ✓
Binary Subtraction — Borrow Method
A
B
Difference
Borrow
0
0
0
0
0
1
1
1
1
0
1
0
1
1
0
0
±️ 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.
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.
Operation
Method
Result valid when…
Positive + Positive
Direct binary addition
No carry out of sign bit
Positive − Positive
Add 2’s complement of subtrahend
Discard final carry; result is correct
Negative + Negative
Add the two 2’s complement representations
Discard carry; both results should be negative
Overflow detection
Carry into sign bit ≠ carry out of sign bit
Overflow 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.
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:
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
Topic
Rule / Formula
Decimal → Binary (integer)
Divide by 2, collect remainders LSB→MSB
Decimal → Binary (fraction)
Multiply by 2, collect integer parts MSB→LSB
Binary → Octal
Group bits in 3s from radix point; each group = one octal digit
Binary → Hex
Group bits in 4s from radix point; each group = one hex digit
1’s Complement
Invert all bits
2’s Complement
Invert all bits then add 1
Subtraction via 2’s comp
A − B = A + (2’s complement of B); discard carry out
Overflow detection
Carry into MSB ≠ carry out of MSB → overflow
Binary multiplication
Shift-and-add; partial product = shifted multiplicand if bit = 1, else 0