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.
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.
Example 1.5 β Fractional Decimal to Binary: 0.625
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.
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