Professional Documents
Culture Documents
EE2026 - L1 - Number Systems
EE2026 - L1 - Number Systems
Digital Fundamentals
Number Systems
Massimo ALIOTO
Dept of Electrical and Computer Engineering
Email: massimo.alioto@nus.edu.sg
• Terminologies
– Radix (or base) Number 1260.25
– Radix point
– Digits and a numeral (0 radix-1)
100 10-1
– Place value (or weight) is in the 103
102
power of the base (positive on the Radix point
left and negative on the right side of integer part fractional part
the radix point
*Weighted sum of each digit (each digit is weighted by its place value)
Number 10110.01
20 2-1
Radix point
24
Decimal Equivalent: 23
N10 = 1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 0 × 20 + 0 × 2 −1 + 1 × 2 −2
1
= 16 + 0 + 4 + 2 + 0 + 0 +
4
= 22.25
(10110.01)2 = (22.25)10
EE2026 Digital Fundamentals - XU YP 4
Hexadecimal number
Radix (r=16) Digits (0 to 15) Hex Dec
0 0
1 1
Number 18F4.2A 2
3
2
4 4
16-2
5 5
163 160 16-1
162 6 6
Decimal Equivalent: Radix point 7 7
9 9
2 10
= 4096 + 2048 + 240 + 4 + + A 10
16 256 B 11
21
= 6388 + C 12
128 (18F4.2A)16 ≅ (6388.16)10 D 13
≈ 6388.16 E 14
0 0
1 1
3 3
4 4
80 8-1 5 5
82
6 6
Decimal Equivalent: Radix point
7 7
N10 = 7 × 82 + 5 × 81 + 4 × 80 + 2 × 8−1 ? 8
? 9
2
= 448 + 40 + 4 + ? 10
8
= 492.25
Decimal equivalent:
(10110.01)2 → 1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 0 × 20 + 0 × 2 −1 + 1 × 2 −2 = (22.25)10
Integer multiple of 2
Multiply by 2:
• Hex Binary
– Each Hex digit 4 Binary bits (digits)
– Or each 4 Binary bits 1 Hex digit (starting from radix point)
• Octal Binary
– Each octal digit 3 Binary bits
– Or each 3 Binary bits 1 Octal digit (starting from radix point)
• Hex Octal
– Use Binary as an intermediate step
– Hex Binary Octal
– Octal Binary Hex
(122137)8 (1 A B)16
For the fractional part: very similar, just group digits by starting from the position
after the radix point
Hex Bin:
(0 . A45F)16
• Addition
• Multiplication
• Subtraction
• Division
• MSB and LSB
• Arithmetic using computer
Addition table:
0+0=0
0+1=1
1 + 1 = 10
Example:
10111 + 110 = 11101
1 1
Carry
10111
+ 110
---------------
11101
Multiplication table:
0x0=0
0x1=0
1x1=1 Example:
10111 x 110 = 10001010
10111 Multiplicand
x 110 Multiplier
---------------
Multiplication: 00000
Shift then Add 10111 Partial products
Only need “add” operation + 1 0 1 1 1
----------------------
10001010 Product
Subtraction table:
0-0=0
1-0=1
1-1=0
0–1=1 with a borrow from the next (higher) bit
Example:
11011 - 110 = 10101
11011
- 110
---------------
10101
• Set quotient to 0
100101/101 = ? • Align leftmost digits in dividend and divisor
• Repeat
• If that portion of the dividend above the
111 quotient divisor is greater than or equal to the
101 100101 divisor
• Then subtract divisor from that
101 portion of the dividend and
• Concatenate 1 to the right hand
1000 end of the quotient
101 • Else concatenate 0 to the right
hand end of the quotient
111 • Shift the divisor one place right
• Until dividend is less than the divisor
101 • quotient is correct, dividend is remainder
10 remainder • STOP
Division (shift and subtract)
Shift then subtraction
Check in decimal Only need “subtract” operation
EE2026 Digital Fundamentals - XU YP 23
Arithmetic using computer
• MSB
– Most significant bit
• LSB
– Least significant bit
1011001
(Left-most bit) MSB LSB (Right-most bit)
Example:
Signed binary number (n bits)
Decimal S-M
3 011
1 0 1 … … 1 0
2 010
1 001 Note:
Magnitude +0 000 Two zeros
-0 100
Sign bit 0 – represents a positive number
-1 101
1 – represents a negative number
-2 110 Negative
MSB is a sign bit numbers
-3 111
A* = rn – A – 1 or A*= (rn – 1) - A
Examples:
Decimal number:
A = 2375 A* = (1000010 – 1) - 237510 = 999910 – 237510 = 762410
A = 0919 A* = (1000010 – 1) - 091910 = 908010
Octal number:
A = 406 A* = (10008 – 1) – 4068 = 7778 – 4068 = 3718
A = 0671 A* = (100008 – 1) – 06718 = 77778 – 06718 = 71068
Hex number:
A = 4A09 A* = (1000016 – 1) – 4A0916 = FFFF16 – 4A0916 = B5F616
A = 0A7F A* = (1000016 – 1) – 0A7F16 = FFFF16 – 0A7F16 = F58016
Binary number:
A = 1001 A* = (100002 – 1) – 10012 = 11112 - 10012 = 01102
A = 1100 A* = (100002 – 1) – 11002 = 11112 – 11002 = 00112
Diminished radix 2 complement
EE2026 Digital Fundamentals - XU YP
is found by reversing the bits 32
1’s Complement
Decimal BCD:
Decimal ( 5 9 8 )10
Note:
Six numbers, from 1010 to 1111,
are not used in BCD.
4 0100
+ 3 + 0011
----- ----------
7 0111
5 0101 8 1000
+ 7 + 0111 + 9 + 1001
----- ---------- ----- ----------
12 1100 17 1 0001
+ 0110 + 0110
---------- -------------
1 0010 1 0111
1 2 1 7