Chapter 3 Data Representation

Slides:



Advertisements
Similar presentations
DATA REPRESENTATION CONVERSION.
Advertisements

Chapter 1 Digital Systems and Numbers System
ENGIN112 L4: Number Codes and Registers ENGIN 112 Intro to Electrical and Computer Engineering Lecture 4 Number Codes and Registers.
CHAPTER 2 Number Systems, Operations, and Codes
Digital Fundamentals Floyd Chapter 2 Tenth Edition
CS 151 Digital Systems Design Lecture 3 More Number Systems.
CS 151 Digital Systems Design Lecture 4 Number Codes and Registers.
CS 151 Digital Systems Design Lecture 2 Number Systems Prof. Ahmed Sameh Room 239A.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
Data Representation in Computers
ENGIN112 L2: Number Systems September 5, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 2 Number Systems Russell Tessier KEB 309 G.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Number Systems and Arithmetic
EE 261 – Introduction to Logic Circuits
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Number Systems and Codes
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numbering systems.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Numbering Systems CS208.
Digital Design: From Gates to Intelligent Machines
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 2 Number.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Number systems & Binary codes MODULE 1 Digital Logic Design Ch1-2 Outline of Chapter 1  1.1 Digital Systems  1.2 Binary Numbers  1.3 Number-base Conversions.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Date: Session III Topic: Number Systems Faculty: Anita Kanavalli Department of CSE M S Ramaiah.
Number systems, Operations, and Codes
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Chapter1: Number Systems
Data Representation, Number Systems and Base Conversions
AEEE2031 Data Representation and Numbering Systems.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Chapter 2 Number Systems Consists of a set of symbols called digits and a set of relations such as +, -, x, /.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
MECH1500 Chapter 3.
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
Computer Number System
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic.
CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh.
Number Systems. ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
CPE 201 Digital Design Lecture 2: Digital Systems & Binary Numbers (2)
NUMBER SYSTEMS.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CHAPTER 1 : INTRODUCTION
Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication.
COMPUTING FUNDAMENTALS
Number Systems Give qualifications of instructors:
Chapter 3 Data Representation
Number System conversions
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Numbering System TODAY AND TOMORROW 11th Edition
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Digital Electronics and Microprocessors
Presentation transcript:

Chapter 3 Data Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009

Data Types The data types stored in digital computers may be classified as being one of the following categories: numbers used in arithmetic computations, letters of the alphabet used in data processing, and other discrete symbols used for specific purposes. All types of data are represented in computers in binary-coded form.

Radix representation of numbers • Radix or base: is the total number of symbols used to represent a value. A number system of radix r uses a string consisting of r distinct symbols to represent a value.

Radix representation of numbers Example: convert the following number to the radix 10 format. 97654.35 The positions indicate the power of the radix. Start from the decimal point right to left we get 0,1,2,3,4 for the whole numbers. And from the decimal point left to right We get -1, -2 for the fractions = 9x104 + 7x103 + 6x102 + 5x101 + 4x100 + 3x10-1 + 5x10-2

Binary Numbers Binary numbers are made of binary digits (bits): 0 and 1 Convert the following to decimal (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10

Example Use radix representation to convert the binary number (101.01) into decimal. The position value is power of 2 1 0 1. 0 1      22 21 20 2-1 2-2 4 + 0 + 1 + 0 + 1/22 = 5.25 (101.01)2  (5.25)10 = 1 x 22 + 0 x 2 + 1 + 0 x 2-1 + 1 x 2-2 6

Binary Addition Example Add (11110)2 to (10111)2 1 1 1 1 1 1 carries 1 1 1 1 0 1 + 1 0 1 1 1 --------------------- 1 1 1 carry (111101)2 + (10111) 2 = (1010100)2

Binary Subtraction 1+1=2 1 10 borrows 0 10 10 0 0 10 1 0 0 1 1 0 1 We can also perform subtraction (with borrows). Example: subtract (10111) from (1001101) 1+1=2 1 10 0 10 10 0 0 10 1 0 0 1 1 0 1 - 1 0 1 1 1 ------------------------ 0 1 1 0 1 1 0 borrows (1001101)2 - (10111)2 = (0110110)2

The Growth of Binary Numbers 20=1 1 21=2 2 22=4 3 23=8 4 24=16 5 25=32 6 26=64 7 27=128 n 2n 8 28=256 9 29=512 10 210=1024 11 211=2048 12 212=4096 20 220=1M 30 230=1G 40 240=1T Mega Giga Tera 9

Octal Numbers Octal numbers (Radix or base=8) are made of octal digits: (0,1,2,3,4,5,6,7) How many items does an octal number represent? Convert the following octal number to decimal (465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2 10

Counting in Octal 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 21 22 23 24 25 26 27 11

Conversion Between Number Bases Octal(base 8) Decimal(base 10) Binary(base 2) Hexadecimal (base16) We normally convert to base 10 because we are naturally used to the decimal number system. We can also convert to other number systems 12

Converting an Integer from Decimal to Another Base For each digit position: Divide the decimal number by the base (e.g. 2) The remainder is the lowest-order digit Repeat the first two steps until no divisor remains. For binary the even number has no remainder ‘0’, while the odd has ‘1’ 13

Converting an Integer from Decimal to Another Base Quotient Remainder Coefficient Example for (13)10: 13/2 = (12+1)½ a0 = 1 6/2 = ( 6+0 )½ a1 = 0 3/2 = (2+1 )½ a2 = 1 1/2 = (0+1) ½ a3 = 1 Answer (13)10 = (a3 a2 a1 a0)2 = (1101)2

Converting a Fraction from Decimal to Another Base For each digit position: Multiply decimal number by the base (e.g. 2) The integer is the highest-order digit Repeat the first two steps until fraction becomes zero.

Converting a Fraction from Decimal to Another Base Example for (0.625)10: Integer Fraction Coefficient 0.625 x 2 = 1 + 0.25 a-1 = 1 0.250 x 2 = 0 + 0.50 a-2 = 0 0.500 x 2 = 1 + 0 a-3 = 1 Answer (0.625)10 = (0.a-1 a-2 a-3 )2 = (0.101)2

DECIMAL TO BINARY CONVERSION (INTEGER+FRACTION) (1) Separate the decimal number into integer and fraction parts. (2) Repeatedly divide the integer part by 2 to give a quotient and a remainder and Remove the remainder. Arrange the sequence of remainders right to left from the period. (Least significant bit first) (3) Repeatedly multiply the fraction part by 2 to give an integer and a fraction part and remove the integer. Arrange the sequence of integers left to right from the period. (Most significant fraction bit first)

. (Example) (41.6875)10 ® (?)2 Integer = 41, Fraction = 0.6875 Integer Overflow Fraction X by 2 .6875 1 .3750 .750 .5 Integer remainder 41 /2 1 20 10 5 2 Closer to the point . The first procedure produces 41 = 32+8+1 = 1 x 25 + 0 x 24 + 1 x 23 + 0 x 22 + 0 x 2 + 1 = (101001)

Converting an Integer from Decimal to Octal For each digit position: Divide decimal number by the base (8) The remainder is the lowest-order digit Repeat first two steps until no divisor remains.

Converting an Integer from Decimal to Octal Example for (175)10: Integer Quotient Remainder Coefficient 175/8 = 21 + 7/8 a0 = 7 21/8 = 2 + 5/8 a1 = 5 2/8 = 0 + 2/8 a2 = 2 Answer (175)10 = (a2 a1 a0)2 = (257)8

Converting an Integer from Decimal to Octal For each digit position: Multiply decimal number by the base (e.g. 8) The integer is the highest-order digit Repeat first two steps until fraction becomes zero.

Converting an Integer from Decimal to Octal Example for (0.3125)10: Integer Fraction Coefficient 0.3125 x 8 = 2 + 0.5 a-1 = 2 0.5000 x 8 = 4 + 0 a-2 = 4 Answer (0.3125)10 = (0.24)8 Combine the two (175.3125)10 = (257.24)8 Remainder of division Overflow of multiplication

Hexadecimal Numbers Hexadecimal numbers are made of 16 symbols: (0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F) Convert a hexadecimal number to decimal (3A9F)16 = 3x163 + 10x162 + 9x161 + 15x160 = 1499910 Hexadecimal with fractions: (2D3.5)16 = 2x162 + 13x161 + 3x160 + 5x16-1 = 723.312510 Note that each hexadecimal digit can be represented with four bits. (1110) 2 = (E)16 Groups of four bits are called a nibble. (1110) 2

Example Convert the decimal number (107.00390625)10 into hexadecimal number. (107.00390625)10  (6B.01)16 Overflow Fraction X by 16 . 00390625 .0625 1 .0000 Integer remainder 107 Divide/16 6 11=B Closer to the period .

One to one comparison Binary, octal, and hexadecimal similar Easy to build circuits to operate on these representations Possible to convert between the three formats

Converting between Base 16 and Base 2 3A9F16 = 0011 1010 1001 11112 3 A 9 F Conversion is easy! Determine 4-bit value for each hex digit Note that there are 24 = 16 different values of four bits which means each 16 value is converted to four binary bits. Easier to read and write in hexadecimal. Representations are equivalent!

Converting between Base 16 and Base 8 3A9F16 = 0011 1010 1001 11112 3 A 9 F 352378 = 011 101 010 011 1112 3 5 2 3 7 Convert from Base 16 to Base 2 Regroup bits into groups of three starting from right Ignore leading zeros Each group of three bits forms an octal digit (8 is represented by 3 binary bits).

Example Convert 101011110110011 to a. octal number b.      hexadecimal number   a.       Each 3 bits are converted to octal : (101) (011) (110) (110) (011)      5 3 6 6 3 101011110110011 = (53663)8 b.      Each 4 bits are converted to hexadecimal: (0101) (0111) (1011) (0011)     5 7 B 3 101011110110011 = (57B3)16 Conversion from binary to hexadecimal is similar except that the bits divided into groups of four.

Binary Coded Decimal Binary coded decimal (BCD) represents each decimal digit with four bits Ex. 0011 0010 1001 = 32910 This is NOT the same as 0011001010012 Why use binary coded decimal? Because people think in decimal. 3 2 9 Digit BCD Code 0000 5 0101 1 0001 6 0110 2 0010 7 0111 3 0011 8 1000 4 0100 9 1001 29

BCD versus other codes BCD not very efficient Used in early computers (40s, 50s) Used to encode numbers for seven- segment displays. Easier to read? (Example) The decimal 99 is represented by 1001 1001. 30

Gray Code Gray code is not a number system. It is an alternative way to represent four bit data Only one bit changes from one decimal digit to the next Useful for reducing errors in communication. Can be scaled to larger numbers. Digit Binary Gray Code 0000 1 0001 2 0010 0011 3 4 0100 0110 5 0101 0111 6 7 8 1000 1100 9 1001 1101 10 1010 1111 11 1011 1110 12 13 14 15 31

ASCII Code American Standard Code for Information Interchange ASCII is a 7-bit code, frequently used with an 8th bit for error detection (more about that in a bit). Character ASCII (bin) ASCII (hex) Decimal Octal A 1000001 41 65 101 B 1000010 42 66 102 C 1000011 43 67 103 … Z a 1 ‘ 32