Positional Number Systems and Polynomial Representation
Numerical data in computing systems is expressed using positional number representation. While the decimal system is ubiquitous in human calculation, practical electronic devices rely primarily on two-state physical elements. Consequently, digital machines represent numbers and perform arithmetic using the binary number system, which utilizes only two symbols: 0 and 1.
An ordinary decimal number represents a polynomial in powers of 10. For example, the decimal number 123.45 represents the polynomial expansion:
123.45=1×102+2×101+3×100+4×10−1+5×10−2
In general positional notation, the number 10 is referred to as the base or radix of the system. In a system with base b, a positive number N represents the polynomial:
The coefficients ai are integers satisfying the inequality 0≤ai≤b−1
The digit sequence aq−1aq−2×××a0 constitutes the integral part of N, comprising q digits.
The digit sequence a−1a−2×××a−p constitutes the fractional part of N, comprising p digits.
A radix point separates the integral and fractional parts.
The digit a−p is the least significant digit (LSD).
The digit aq−1 is the most significant digit (MSD).
When the base b=2, the system is called the binary number system. For example, the binary number 1101.012 represents the polynomial expansion:
1101.012=1×23+1×22+0×21+1×20+0×2−1+1×2−2
Evaluating this polynomial gives 8+4+0+1+0+0.25=13.2510. Formally, this binary number is expressed as:
1101.012=∑i=−23ai2i
where a−2=1, a−1=0, a0=1, a1=0, a2=1, and a3=1
A number N in base b is denoted as (N)b. When the base is omitted, base 10 is implicitly assumed.
Representations of Integers in Various Bases
Base 2
Base 4
Base 8
Base 10
Base 12
0000
0
0
0
0
0001
1
1
1
1
0010
2
2
2
2
0011
3
3
3
3
0100
10
4
4
4
0101
11
5
5
5
0110
12
6
6
6
0111
13
7
7
7
1000
20
10
8
8
1001
21
11
9
9
1010
22
12
10
α
1011
23
13
11
β
1100
30
14
12
10
1101
31
15
13
11
1110
32
16
14
12
1111
33
17
15
13
Digit Complements
The complement of a digit a, denoted a′, in base b is defined as the difference between the largest allowable digit in base b and the digit a:
a′=(b−1)−a
In the binary number system (b=2), the complements are 0′=1 and 1′=0. This is known as the 1's complement.
In the decimal number system (b=10), the largest digit is 9. The complement of a digit a is 9−a, known as the 9's complement. For example, the 9's complement of 3 is 9−3=6
Number System Base Conversions
When converting a number (N)b1 from base b1 to base b2, two operational cases are distinguished based on which base arithmetic is used.
Case 1: Conversion when b1<b2
When b1<b2, it is convenient to use base-b2 arithmetic. The number (N)b1 is expressed as a polynomial in powers of b1, and the terms are evaluated using base-b2 arithmetic operations.
Conversion Example: Octal to Decimal (b1=8, b2=10)
The remainder of this division equals the least significant digit a0. Dividing the quotient Q0 by b2 gives:
b2Q0=aq−1b2q−3+×××+a2+b2a1=Q1+b2a1
This process of successive division is repeated until the quotient Qq−1=0. The remainders generated at each step correspond to the digits a0,a1,…,aq−1.
Integer Example 1: Decimal (548)10 to Octal (b2=8)
Division (Qi=Qi−1/8)
Quotient Qi
Remainder ri=ai
548/8
68
4=a0
68/8
8
4=a1
8/8
1
0=a2
1/8
0
1=a3
Result: (548)10=(1044)8
Integer Example 2: Decimal (345)10 to Base 6 (b2=6)
Division (Qi=Qi−1/6)
Quotient Qi
Remainder ri=ai
345/6
57
3=a0
57/6
9
3=a1
9/6
1
3=a2
1/6
0
1=a3
Result: (345)10=(1333)6
Reconversion check to Base 10: (1333)6=1×63+3×62+3×61+3×60=216+108+18+3=(345)10
Fractional Part Conversion Algorithm
For a fraction (N)b1 expressed in base b2 as:
(N)b1=a−1b2−1+a−2b2−2+×××+a−pb2−p
Multiplying (N)b1 by b2 yields:
b2×(N)b1=a−1+a−2b2−1+×××+a−pb2−p+1
If this product is less than 1, then a−1=0
If this product is greater than or equal to 1, then a−1 equals the integral part of the product.
The next digit a−2 is found by multiplying the remaining fractional part by b2 and extracting its integral part. This process is repeated for successive digits. It does not necessarily terminate if the fraction cannot be represented exactly with a finite number of digits in base b2
Fractional Example 1: Decimal (0.3125)10 to Octal (b2=8)
0.3125×8=2.5000⟹ Integral part a−1=2
0.5000×8=4.0000⟹ Integral part a−2=4
Result: (0.3125)10=(0.24)8
Fractional Example 2: Decimal (0.375)10 to Binary (b2=2)
0.375×2=0.750⟹ Integral part a−1=0
0.750×2=1.500⟹ Integral part a−2=1
0.500×2=1.000⟹ Integral part a−3=1
Result: (0.375)10=(0.011)2
Fractional Example 3: Decimal (432.354)10 to Binary (b2=2)
Integral Part Conversion (43210):
Division
Quotient Qi
Remainder ri=ai
432/2
216
0=a0
216/2
108
0=a1
108/2
54
0=a2
54/2
27
0=a3
27/2
13
1=a4
13/2
6
1=a5
6/2
3
0=a6
3/2
1
1=a7
1/2
0
1=a8
Integral result: (432)10=(110110000)2
Fractional Part Conversion (0.35410):
0.354×2=0.708⟹a−1=0
0.708×2=1.416⟹a−2=1
0.416×2=0.832⟹a−3=0
0.832×2=1.664⟹a−4=1
0.664×2=1.328⟹a−5=1
0.328×2=0.656⟹a−6=0
0.656×2=1.312⟹a−7=1
Fractional result: (0.354)10=(0.0101101…)2
Combined conversion: (432.354)10=(110110000.0101101…)2 Reconversion to base 10 of this truncated representation yields (432.3515)10.
Direct Base Conversion Shortcut (b2=b1k)
When converting between bases where b2=b1k, grouping digits allows immediate conversion without intermediate polynomial arithmetic.
Octal to Binary and Binary to Octal (8=23,k=3)
Each octal digit maps directly to a group of three binary digits, starting from the radix point.
Octal to Binary: (123.4)8=(001010011.100)2
Binary to Octal: (1010110.0101)2=(001010110.010100)2=(126.24)8
Binary to Hexadecimal (16=24,k=4)
Conversion to hexadecimal uses groups of four binary digits for each hex digit.
Binary Arithmetic Operations
Binary arithmetic follows rules analogous to decimal arithmetic. The fundamental single-bit operations are summarized below.
Elementary Binary Operations
Bit a
Bit b
Sum a+b
Carry
Difference a−b
Borrow
Product a⋅b
0
0
0
0
0
0
0
0
1
1
0
1
1
0
1
0
1
0
1
0
0
1
1
0
1
0
0
1
Addition
Binary addition adds corresponding bits starting from the least significant position. If a carry of 1 is produced, it is added to the next column to the left.
When subtracting bits a−b, if a borrow of 1 occurs:
If the next left digit of the minuend is 1, it is changed to 0, and subtraction proceeds.
If the next left digit of the minuend is 0, it is changed to 1, as is each successive minuend digit to the left that equals 0. The first minuend digit to the left that equals 1 is changed to 0, and subtraction continues.
Human-machine communication requires representing the 10 decimal digits (0,1,…,9) in binary form. At least 4 binary digits (bits) are necessary, as 23=8<10 and 24=16≥10. Since 4 bits afford 16 distinct combinations, multiple code mappings exist.
In a weighted code, each binary position is assigned a specific numerical weight w1,w2,w3,w4. A decimal digit N represented by the binary sequence x4x3x2x1 satisfies:
N=w4x4+w3x3+w2x2+w1x1
The binary sequence x4x3x2x1 is called a code word.
Examples of Weighted Binary Codes
Decimal Digit
BCD (8 4 2 1)
2 4 2 1 Code
6 4 2 -3 Code
0
0000
0000
0000
1
0001
0001
0101
2
0010
0010
0010
3
0011
0011
1001
4
0100
0100
0100
5
0101
1011
1011
6
0110
1100
0110
7
0111
1101
1101
8
1000
1110
1010
9
1001
1111
1111
Code Characteristics and Properties
Binary-Coded-Decimal (BCD) / 8 4 2 1 Code: Weights are 8,4,2,1. Each decimal digit maps directly to its traditional 4--bit binary equivalent. For example, decimal 5 is 01012, since 8(0)+4(1)+2(0)+1(1)=5
Negative Weights: Weights can be negative, as in the (6,4,2,−3) code. In this code, decimal 5 is represented as 10112 because: 6(1)+4(0)+2(1)+(−3)(1)=6+0+2−3=5
Self-Complementing Codes: A code is self-complementing if the code word for the 9's complement of N (i.e., 9−N) is obtained by bitwise inversion (interchanging all 1s and 0s) of the code word for N
In the (2,4,2,1) code: Decimal 2 is 0010. Its 9's complement, decimal 7, is 1101 (the bitwise inversion of 0010).
In the (6,4,2,−3) code: Decimal 3 is 1001. Its 9's complement, decimal 6, is 0110 (the bitwise inversion of 1001).
The standard BCD (8421) code is not self-complementing. Theorem on Self-Complementing Codes: A necessary condition for a weighted code to be self-complementing is that the sum of its weights must equal 9: ∑i=14wi=9
There exist only four positively weighted self-complementing codes: (2,4,2,1), (3,3,2,1), (4,3,1,1), and (5,2,1,1).
There exist 13 self-complementing codes utilizing both positive and negative weights.
Nonweighted Binary Codes and Gray Code
Nonweighted codes do not assign positional values to bit positions.
Nonweighted Codes Comparison
Decimal Digit
Excess-3 Code
Cyclic Code
0
0011
0000
1
0100
0001
2
0101
0011
3
0110
0010
4
0111
0110
5
1000
0111
6
1001
1011
7
1010
1001
8
1011
1100
9
1100
0100
Excess-3 Code
The Excess-3 code is derived by adding 00112 (310) to each standard BCD code word. For instance, decimal 7 in Excess-3 is:
01112+00112=10102
Excess-3 is a self-complementing code. For example, decimal 2 (01012) and decimal 7 (10102) are bitwise inversions of each other.
Cyclic Codes
Cyclic codes have the property that adjacent code words differ in exactly one bit position. In addition, the code words for decimal 0 and decimal 9 differ in only one bit position.
Gray Code
The Gray code is a fundamental cyclic code widely used in analog-to-digital conversion and shaft encoders.
Complete Four-Bit Gray Code
Decimal Number
Gray Code (g3g2g1g0)
Binary Number (b3b2b1b0)
0
0000
0000
1
0001
0001
2
0011
0010
3
0010
0011
4
0110
0100
5
0111
0101
6
0101
0110
7
0100
0111
8
1100
1000
9
1101
1001
10
1111
1010
11
1110
1011
12
1010
1100
13
1011
1101
14
1001
1110
15
1000
1111
Binary to Gray Code Conversion
Let gn…g1g0 denote an (n+1)--bit Gray code word, and bn…b1b0 denote the corresponding binary number (where subscript 0 is the LSB and n is the MSB).
Each Gray bit gi is calculated as:
gi=bi⊕bi+1for 0≤i≤n−1
gn=bn
where ⊕ represents the modulo-2 sum (Exclusive-OR):
0⊕0=0
0⊕1=1
1⊕0=1
1⊕1=0
Binary to Gray Example
Convert binary 1011012 (b5b4b3b2b1b0) to Gray code:
g5=b5=1
g4=b5⊕b4=1⊕0=1
g3=b4⊕b3=0⊕1=1
g2=b3⊕b2=1⊕1=0
g1=b2⊕b1=1⊕0=1
g0=b1⊕b0=0⊕1=1
Result: Gray code word is 111011
Gray Code to Binary Conversion Algorithm
To convert from Gray code to binary, evaluate bits from MSB to LSB:
Set bn=gn
For i<n:
Set bi=gi if the number of 1s preceding gi in the Gray word is even (zero is considered an even count).
Set bi=gi′ (complement of gi) if the number of 1s preceding gi is odd.
Gray to Binary Example
Convert Gray code 1001011 to binary:
b6=g6=1
Preceding 1s for g5(0) is 1 (odd) ⟹b5=0′=1
Preceding 1s for g4(0) is 1 (odd) ⟹b4=0′=1
Preceding 1s for g3(1) is 1 (odd) ⟹b3=1′=0
Preceding 1s for g2(0) is 2 (even) ⟹b2=0
Preceding 1s for g1(1) is 2 (even) ⟹b1=1
Preceding 1s for g0(1) is 3 (odd) ⟹b0=1′=0
Result: Binary number is 11100102
Reflected Code Construction
An n--bit Gray code is generated by reflecting an (n−1)--bit code about a central axis, then prefixing a MSB of 0 above the axis and 1 below the axis.
Error-Detecting Binary Codes and Parity Schemes
Physical transmission channels are prone to electronic noise and component failures. While the probability of a single-bit error is finite, simultaneous multiple-bit errors occur with significantly lower probability.
Minimum Distance of a Code
The distance between two binary code words is the number of digit positions in which they differ. For example, the distance between 1010 and 0100 is 3
The minimum distance (dmin) of a code is the smallest distance between any pair of valid code words in that code:
Standard BCD and Excess-3 have dmin=1
A code is single-error-detecting if and only if dmin≥2
To create an n--bit single-error-detecting code, no more than half of the possible 2n combinations can be used (2n−1 words). To encode 10 decimal digits with error detection, at least 5 bits are required (25−1=16≥10).
Parity Check Methods
A parity bit p is appended to each code word to ensure the total count of 1s across all digits is either even (even parity) or odd (odd parity). Even parity detects any odd number of bit errors.
Error-Detecting Codes Comparison
Decimal Digit
Even-Parity BCD (8 4 2 1 p)
2-out-of-5 Code (0 1 2 4 7)
0
00000
00011
1
00011
11000
2
00101
10100
3
00110
01100
4
01001
10010
5
01010
01010
6
01100
00110
7
01111
10001
8
10001
01001
9
10010
00101
Even-Parity BCD: Appends a 5th parity bit p to standard BCD to maintain an even total count of 1s.
2-out-of-5 Code: Each 5-bit word contains exactly two 1s. Except for decimal 0, it is derived from the weighted (1,2,4,7) code. Any single bit flip transforms a valid word into an invalid word containing either one or three 1s, triggering detection.
Error-Correcting Codes and Hamming Code Construction
To correct errors automatically, the minimum distance must be increased:
dmin=3: Allows single-error correction OR double-error detection.
dmin=4: Allows single-error correction AND double-error detection simultaneously.
Hamming Error-Correcting Code
A Hamming code adds k parity-checking bits (p1,p2,…,pk) to m message bits to form an (m+k)--bit code word. The bit positions are numbered 1 through m+k, starting from position 1 at the MSB.
Mathematical Constraint on Check Bits
The number of check bits k must be sufficient to identify all m+k single-error positions, plus the "no error" condition:
2k≥m+k+1
For a BCD message (m=4): 2k≥4+k+1⟹2k≥5+k
The smallest integer satisfying this is k=3. Thus, the total code length is m+k=7 bits.
Bit Placement Rule
To allow check bits to be computed independently, parity bits are placed at positions corresponding to powers of 2: positions 1,2,4,…,2k−1.
For m=4,k=3:
Position 1: Parity bit p1
Position 2: Parity bit p2
Position 3: Message bit m1
Position 4: Parity bit p3
Position 5: Message bit m2
Position 6: Message bit m3
Position 7: Message bit m4
Position Number Table
Each parity check targets specific positions such that the resulting binary evaluation c3c2c1 (the position or syndrome number) directly indicates the 1-based decimal index of the erroneous bit. If c3c2c1=000, no error has occurred.
Error Position
Position Number (c3c2c1)
Parity Checks Involved
0 (No error)
000
None
1
001
p1 check (positions 1, 3, 5, 7)
2
010
p2 check (positions 2, 3, 6, 7)
3
011
p1,p2 checks
4
100
p3 check (positions 4, 5, 6, 7)
5
101
p1,p3 checks
6
110
p2,p3 checks
7
111
p1,p2,p3 checks
Parity Generation Rules
p1 is chosen to establish even parity across positions 1,3,5,7
p2 is chosen to establish even parity across positions 2,3,6,7
p3 is chosen to establish even parity across positions 4,5,6,7
Complete Hamming Code for BCD
Decimal Digit
Pos 1 (p1)
Pos 2 (p2)
Pos 3 (m1)
Pos 4 (p3)
Pos 5 (m2)
Pos 6 (m3)
Pos 7 (m4)
0
0
0
0
0
0
0
0
1
1
1
0
1
0
0
1
2
0
1
0
1
0
1
0
3
1
0
0
0
0
1
1
4
1
0
0
1
1
0
0
5
0
1
0
0
1
0
1
6
1
1
0
0
1
1
0
7
0
0
0
1
1
1
1
8
1
1
1
0
0
0
0
9
0
0
1
1
0
0
1
Step-by-Step Error Correction Example
Suppose decimal digit 1 (1101001) is transmitted, but bit 5 experiences an error, resulting in 1101101
Perform parity checks on received bits (1101101):
4-5-6-7 Parity Check: Bits at positions 4, 5, 6, 7 are 1,1,0,1. Sum = 3 (odd) ⟹c3=1
2-3-6-7 Parity Check: Bits at positions 2, 3, 6, 7 are 1,0,0,1. Sum = 2 (even) ⟹c2=0
1-3-5-7 Parity Check: Bits at positions 1, 3, 5, 7 are 1,0,1,1. Sum = 3 (odd) ⟹c1=1
The error position number c3c2c1=1012=510. This isolates the error precisely to position 5. Complementing position 5 (1→0) recovers the correct code word 1101001
Extended Hamming Code (dmin=4)
By adding an 8th overall parity bit (p4) covering all 7 previous bits:
If an overall parity error occurs AND c3c2c1=000, a single error occurred at position c3c2c1
If overall parity is satisfied BUT c3c2c1=000, a double error occurred.
If overall parity fails AND c3c2c1=000, the 8th parity bit itself is in error.
Comprehensive Chapter Problems and Analytical Solutions
Problem 1-1: Base Conversions
Perform the following conversions:
(a) (1431)8 to base 10:1×83+4×82+3×81+1×80=512+256+24+1=(793)10
(b) 11001010.01012 to base 10:27+26+23+21+2−2+2−4=128+64+8+2+0.25+0.0625=(202.3125)10