Professional Documents
Culture Documents
TOPIC 1
DIGITAL SYSTEMS AND BINARY NUMBERS
* Slides are used as an aiding tool to teach in the classroom. Not every
information/details that will be taught in the classes are mentioned on the slides.
Hence, you are expected to follow the given textbook(s) for your course.
Digital Systems are everywhere!
• Digital Communication Systems.
• Transportation of information in digital electronic form.
• HDTV, digital satellite radio, etc.
• Mobile phone technology: iPhones, Androids, etc.
• The Internet!
• Computer Systems.
• Calculators, PCs, parallel computing and
supercomputers.
• Games consoles (PlayStation 4, Xbox One, Wii U).
• Microcontrollers and embedded systems.
- FHE
• Consumer electronics.
– Audio recordings on CDs stored as 16-bit signed integers,
44.1 KHz sample rate.
– iPods, MP3 players.
– DVDs, Blu-Ray, 4K discs. Podcasts, video on demand.
– Smart phones, Handheld and mobile GPS systems.
• Digital signal processing systems.
– Extracting useful information from digitized electric signals.
– Remote sensing, satellite technology.
– Solar system exploration (e.g., the moon, asteroids, all of
the planets).
– Advanced robotics, autonomous vehicles.
- FHE
TWO WAYS OF NUMERICAL REPRESENTATION
OF A QUANTITY: ANALOG VS. DIGITAL
• Real-world “Analog” signals.
In the real world of electrical systems, electrical quantities such as
voltage and current are continuous-level as a function of
continuous-time, i.e., analog data can vary over a continuous range
of values.
- FHE
DIGITAL AND ANALOG SYSTEM
• An analog system contains devices that manipulate
physical quantities that are represented in analog
form. In an analog system, the quantities can vary
over a continuous range of values.
• Some common analog systems are old radios, audio
amplifiers etc.
- FHE
ADVANTAGE OF USING DIGITAL SYSTEM
- FHE
Solution: Back and forth between digital and analog signals
We must be able to convert analog voltages to numbers, and
also convert numbers back to analog voltages.
- FHE
DIGITAL NUMBER SYSTEM
• Many number systems are in use in digital technology.
- FHE
NUMBER SYSTEMS AND CODES
Digital Systems are built from circuits that process binary digits.
But very few real-life problems are based on binary numbers.
- FHE
INFORMATION REPRESENTATION
▪ Elementary storage units inside computer can be considered as electronic
switches. Each switch holds one of two states: on (1) or off (0).
ON OFF
- FHE
The Decimal Number System
• The primary number system used is a base ten number system.
• Base 10 number systems are called decimal number systems.
Ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
• Positional value may be stated as a digit multiplied by a power of 10.
104
106 105 103 102 101 100 10-110-210
-3 9735.2 =(9 * 103)
+ (7 * 102)
+ (3 * 101)
+ (5 * 100)
+ (2 * 10-1)
- FHE
General Rule of Number Representation
A number in base (also known as radix) r contains r digits: 0, 1, 2, . .
., r -1, and is expressed as a power series in r with the general form:
a3a2a1a0 . a-1a-2= a3*r3 + a2*r2 + a1*r1 + a0*r0 + a-1*r-1 + a-2*r-2
* In decimal (base 10) number system, the coefficients aj are any of the 10
digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Also, radix point is known as decimal point.
- FHE
Different Number Systems
➢ Octal Number System (base 8): Number system with only
eight numerals : 0, 1, 2, 3, 4, 5, 6, 7
- FHE
IMPORTANT FACT
• The more compact representation of binary numbers in either octal or
hexadecimal is much more convenient for people than using bit strings
in binary that are three or four times as long. Thus, most computer
manuals use either octal or hexadecimal numbers to specify binary
quantities.
- FHE
Number Conversion
From any base or Radix r to Decimal or base 10:
i= 0 to n (a i r i) +
j= 1 to m (a j r -j)
- FHE
Example : Base-r to Decimal Conversion
Octal to Decimal
(127.4)8 = 1x82 + 2x81 + 7x80 + 4x8-1 = (87.5)10
Binary to Decimal
(110101)2 = 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20 = (53)10
Base-5 to Decimal
(4021.2)5 = 4x53 + 0x52 + 2x51 + 1x50 + 2x5-1 = (511.4)10
- FHE
EXERCISE!
Convert Hexadecimal number (B65F)16 to Decimal number
Hexadecimal Decimal
0 to 9 0 to 9
A 10
B 11
C 12
D 13
E 14
F 15
- FHE
• Solution:
- FHE
Converting Decimal integer to any Base-r
General Rule:
▪ Simply repeat dividing the number and all successive quotients
by r and saving the remainder
- FHE
Converting Decimal to Binary
(1) 105 / 2 = 52 1 1
(2) 52 / 2 = 26 0 01
(3) 26 / 2 = 13 0 001
(4) 13 / 2 = 6 1 1001
(5) 6/2= 3 0 01001
(6) 3/2= 1 1 101001
(7) 1/2= 0 1 1101001
So 105 in decimal is written as 1101001 in binary.
- FHE
Converting Decimal to Octal
- FHE
Converting Decimal to Hex
- FHE
Converting Decimal fraction number to Base-r
General Rule:
▪ First integer will be the fast digit from left after the
radix point, Second integer will be the second digit
from the left after radix point ….. and so on
- FHE
Converting Decimal fraction number to Base-r
Example: convert (0.6875)10 to binary Base-2
Integer Fraction Coefficient
(0.6875)10 = (0.1011)2
- FHE
Conversion of Decimal number with radix point to Base-r
▪Separate the integer and fraction part
▪Convert the integer and fraction point to Base-r number
separately
▪Combining the two answer
Example : conversion of (105.6875)10 to Binary
Separate the Integer and Fraction parts
(105.6875)10 = (105)10 + (0.6875)10
7 5 6 3 0 2 1
111 101 110 011 000 010 001
So 10110100111100101101001011 (binary)
= (2D3CB8B)16 (hex)
= (264745513)8 (octal) - FHE
Converting from Hex to Binary
6 F 0 3 7 C 2
0110 1111 0000 0011 0111 1100 0010
(6F037C2)16 is (110111100000011011111000010)2.
- FHE
SIGNED BINARY NUMBERS
❖2s Complement
- FHE
SIGN-AND-MAGNITUDE
▪ Negative numbers are usually written by writing a minus sign in front.
❖Example:
- (12)10 , - (1100)2
- FHE
SIGN-AND-MAGNITUDE
▪ Example: an 8-bit number can have 1-bit sign and 7-bits
magnitude.
sign magnitude
- FHE
SIGNED MAGNITUDE
▪ Largest Positive Number: 0 1111111 +(127)10
▪ Largest Negative Number: 1 1111111 -(127)10
▪ Zeroes: 0 0000000 +(0)10
1 0000000 -(0)10
▪ Range: -(127)10 to +(127)10
▪ Signed numbers needed for negative numbers.
▪ Representation: Sign-and-magnitude.
- FHE
1’s Complement
▪ Given a number x which can be expressed as an n-bit binary number, its
negative value can be obtained in 1’s-complement representation using:
- x => 2n - x - 1
- FHE
1’s Complement
▪ Essential technique: invert all the bits.
- FHE
1’s Complement
- FHE
2’s Complement
▪ Given a number x which can be expressed as an n-bit binary number, its
negative number can be obtained in 2’s-complement representation using:
- x = 2n - x
- FHE
2’s Complement
▪ Essential technique: invert all the bits and add 1.
Examples:
2s complement of
-(00000001)2 = (11111110)1s (invert)
= (11111111)2s (add 1)
2s complement of
-(01111110)2 = (10000001)1s (invert)
= (10000010)2s (add 1)
* Similarly, the 2’s complement can be formed by leaving all least significant 0’s and
the first 1 unchanged an replacing 1’s with 0’s and 0’s with 1’s in all other higher
significant digits.
- FHE
2’s Complement
- FHE
2’s Complement
- FHE
COMPARISONS OF SIGN-AND-MAGNITUDE AND
COMPLEMENTS
▪ Example: 4-bit signed number (positive values)
Value Sign-and- 1s 2s
Magnitude Comp. Comp.
+7 0111 0111 0111
+6 0110 0110 0110
+5 0101 0101 0101
+4 0100 0100 0100
+3 0011 0011 0011
+2 0010 0010 0010
+1 0001 0001 0001
+0 0000 0000 0000
- FHE
COMPARISONS OF SIGN-AND-MAGNITUDE AND
COMPLEMENTS
▪ Example: 4-bit signed number (negative values)
Value Sign-and- 1s 2s
Magnitude Comp. Comp.
-0 1000 1111 -
-1 1001 1110 1111
-2 1010 1101 1110
-3 1011 1100 1101
-4 1100 1011 1100
-5 1101 1010 1011
-6 1110 1001 1010
-7 1111 1000 1001
-8 - - 1000
- FHE
BINARY ARITHMETIC OPERATIONS
FOR UNSIGNED NUMBERS
▪ ADDITION
▪ Like decimal numbers, two numbers can be added by
adding each pair of digits together with carry propagation.
(11011)2 (647)10
+ (10011)2 + (537)10
(101110)2 (1184)10
* Remember, in binary, 0+0=0, 1+0 = 1, 1+1 = 10, 1+1+1 = 11. When the addition results
in a 2 digits number (i.e. 10, 11), the most significant bit (MSB) propagates (if applicable)
to the next stage.
- FHE
BINARY ARITHMETIC OPERATIONS
FOR UNSIGNED NUMBERS
▪ SUBTRACTION
▪ Two numbers can be subtracted by subtracting each pair
of digits together with borrowing, where needed.
(11001)2 (627)10
- (10011)2 - (537)10
(00110)2 (090)10
- FHE
PROBLEM IN SIGNED ARITHMETIC
OPERATION: OVERFLOW
▪ Signed binary numbers are of a fixed range.
▪ If the result of addition/subtraction goes beyond this range, overflow occurs.
▪ Two conditions under which overflow can occur are:
(i) positive add positive gives negative
(ii) negative add negative gives positive
- FHE
OVERFLOW
▪ Examples: 4-bit numbers (in 2’s complement)
▪ Range: (1000)2s to (0111)2s or (-810 to 710)
(i) (0101)2s + (0110)2s= (1011)2s
(5)10 + (6)10= -(5)10 ?! (overflow!)
- FHE
2’s Complement Addition/Subtraction
- FHE
2’s Complement Addition/Subtraction
- FHE
2’s Complement Addition/Subtraction
- FHE
1’s Complement Addition/Subtraction
- FHE
1’s Complement Addition/Subtraction
▪ Examples: 4-bit binary system
+3 0011 +5 0101
+ +4 + 0100 + -5 + 1010
---- ------- ---- -------
+7 0111 -0 1111
---- ------- ---- -------
-2 1101 -3 1100
+ -5 + 1010 + -7 + 1000
---- ------ ---- -------
-7 10111 -10 10100
---- + 1 ---- + 1
------ -------
1000 0101
- FHE
BCD CODE
• Binary Coded Decimal (BCD) is a widely used way to present decimal
numbers in binary form.
• Combines features of both decimal and binary systems.
• Each digit is converted to a binary equivalent (requires 4 bits).
• BCD is also known as the 8421 code.
• Suitable for interfaces such as keypad inputs and digital readouts.
• BCD is not a number system.
• It is a decimal number with each digit encoded to its binary equivalent.
• A BCD number is not the same as a straight binary number.
• The primary advantage of BCD is the relative ease of converting to and from
decimal.
- FHE
BCD CODE
• Convert the number 87410 to BCD:
• Each decimal digit is represented using 4 bits.
• Each 4-bit group can never be greater than 9.
8 7 4 (Decimal)
9 4 3 (Decimal)
- FHE
BCD CODE
• Convert 0110100000111001 (BCD) to its decimal equivalent.
- FHE
BCD CODE
• Convert BCD 011111000001 to its decimal equivalent.
- FHE
BCD Addition
Consider the addition of (184+576) in BCD:
BCD:
1 1 Carry-out from Previous Stage
0001 1000 0100 184 (Decimal)
+0101 0111 0110 +576 (Decimal)
Binary Sum: 0111 10000 1010
Add 6: 0110 0110
___________________________________________
BCD Sum: 0111 0110 0000 760
* If the binary sum is greater than or equal to 1010, we add 0110 to the
binary sum to obtain the correct BCD sum and a carry.
- FHE
THE GRAY CODE
• The Gray code is used in applications where numbers change rapidly.
• Only one bit changes from each value to the next.
- FHE
THE GRAY CODE
- FHE
PUTTING IT ALL TOGETHER
Decimal numbers 1 – 15 in binary, hex, BCD, Gray
- FHE