King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.

Slides:



Advertisements
Similar presentations
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Advertisements

Lecturer: Omid Jafarinezhad Sharif University of Technology Department of Computer Engineering 1 Fundamental of Programming (C) Lecture 2 Number Systems.
COMP3221: Microprocessors and Embedded Systems--Lecture 1 1 COMP3221: Microprocessors and Embedded Systems Lecture 3: Number Systems (I)
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
CS 61C L02 Number Representation (1)Harvey / Wawrzynek Fall 2003 © UCB 8/27/2003  Brian Harvey ( John Wawrzynek  (Warznek) (
King Fahd University of Petroleum and Minerals
Data Representation Computer Organization &
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Data Representation COE 205
Introduction to Programming with Java, for Beginners
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
1 CSE1301 Computer Programming Lecture 28 Number Representation (Integer)
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Data Representation ICS 233
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Number System and Codes
Computer Science 101 Number Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.
Number Systems Computer Science 210 Computer Organization.
+ CS 325: CS Hardware and Software Organization and Architecture Integers and Arithmetic.
Dr. Bernard Chen Ph.D. University of Central Arkansas
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Simple Data Type Representation and conversion of numbers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Lecture 5.
Computers Organization & Assembly Language
Digital Design: From Gates to Intelligent Machines
IT253: Computer Organization
Binary Arithmetic & Data representation
Data Representation and Computer Arithmetic
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
CE1111 :Digital Logic Design lecture 01 Introduction Dr. Atef Ali Ibrahim.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Data Representation, Number Systems and Base Conversions
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
Data Representation.
Chapter 1 Number Systems Digital Electronics. Topics discussed in last lecture Digital systems Advantages of using digital signals over analog. Disadvantages.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
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.
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
Data Representation COE 308 Computer Architecture
Computer Science 210 Computer Organization
Topic: Binary Encoding – Part 1
Data Representation ICS 233
Lec 3: Data Representation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CSE 102 Introduction to Computer Engineering
University of Gujrat Department of Computer Science
Data Representation COE 301 Computer Organization
King Fahd University of Petroleum and Minerals
Computer Science 210 Computer Organization
Data Representation ICS 233
Data Representation COE 308 Computer Architecture
Presentation transcript:

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 1 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Lecture 5: Data Representation

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 2 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Data in Computers Computers understand binary numbers only: Numbers: –Represented in binary Integers:+33, -37, +267 Reals: E16, E-12 Characters: Alphanumeric: A, c, Ctrl, Shift –Represented by numeric codes Multimedia –Still Images: Many formats, all numeric. Based on numeric representation of the RGB components of each point of the image (pixel) –Video Images: Many formats also. Based on same principal as still images but applied on moving portions of the image only. –Sounds: Many formats. All numeric. Based on numeric representation of the amplitude of the sound wave over time. Records and Database Elements: –Combination of Alphanumeric strings and numbers Scientific Data –Combination of Numbers, Records, Multimedia and Statistical Data (numbers)

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 3 © 2005 Dr. Abdelhafid Bouhraoua COE 205 What need to be represented From CPU point of view:ONLY Binary To Standardize: At CPU Level Need to represent: Numbers Characters No need to represent other items –No need to represent Images at CPU level –No need to represent Sounds at CPU level –No need to represent records at CPU level –Taken care by HL language constructs –Goal: Machine independent representation: STANDARD Represent ONLY Numbers and Characters

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 4 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Numbering Systems N = d w-1 B w-1 +…+ d i B i + d 1 B 1 +d 0 B 0 d i : digits;B: Base d i in [0, B-1] Numbering SystemBaseDigits Set Binary20, 1 Octal80, 1, 2, 3, 4, 5, 6, 7 Decimal100, 1, 2, 3, 4, 5, 6, 7, 8, 9 Hexadecimal160, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F (728) 10 = ( ) 2 = (1330) 8 = (2D8) d = b = 1330o = 2D8h

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 5 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Number Conversion Binary - Hexadecimal Hexa- decimal Bin.Sym A 1011B 1100C 1101D 1110E 1111F Binary to Hexadecimal D6C Conversion Table Lookup Hexadecimal to Binary 5D1F Conversion Table Lookup Octal Bin.Sym Binary to Octal Octal to Binary 5361 Conv. Table Lookup Hex  Octal: Go to Binary First

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 6 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Number Conversion Decimal – Binary, Octal, Hex Binary, Octal, Hex  Decimal: –Represent the number in base 10 and compute the operations: –110110b = 1x x x x x x2 0 = 54 –236o = 2x x x8 0 = 158 –3Ch = 3x Cx16 0 = 60 Decimal  Binary, Octal, Hex –Remainder Set of Successive Division by Target Base (2, 8 or 16) N = Q 0 x 2 + R 0 First Division Q 0 = Q 1 x 2 + R 1 Second Division Q 1 = Q 2 x 2 + R 2 Third Division …. Q n-1 = 0 x 2 + R n Cannot divide anymore N = (((((…(R n x2) x 2 + R n-1 ) x 2 +.) x2 + …..x2 + R 1 ) x2 + R 0 N = R n x 2 n + R n-1 x 2 n-1 + ….. + R 1 x 2 + R 0

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 7 © 2005 Dr. Abdelhafid Bouhraoua COE 205 ACSII or Decimal vs Binary Numbers Attractive because: Human- Friendly representation Non attractive to computers: –Understand only binary –Binary operations easy to perform –Does not know how to perform operations on ASCII or Decimal number. –Need to convert ASCII/Decimal to binary before and after operation Used only for I/O (User Interface) Use Binary Representation For Internal Computations Convert to/from ASCII for I/O Only

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 8 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Number Representation Numbers in computers –Just a representation of real numbers –Real numbers have an infinite number of digits 153 ten = … … two = two in a 16 bits word Add, Subtract, Multiply, Divide Result bigger than number of available slots (bits) Overflow

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 9 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Signed Numbers Subtraction of a big number from small number is a negative number Need for Signed Numbers Representation Three Main ways: –Sign + Magnitude –1’s Complement –2’s Complement

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 10 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Sign and Magnitude Intuitive Representation: Sign + Magnitude SignMagnitude Range [-2 n-1 -1, +2 n-1 -1] –8 bits: [-127, +127] –12 bits: [-2047, +2047] Advantages: Straight Forward Disadvantages –Has the problem of double representing the 0 (–0 and +0), –Complicates the design of the logic circuits that handle signed-numbers arithmetic

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 11 © 2005 Dr. Abdelhafid Bouhraoua COE 205 One’s Complement Negative numbers are bit-to-bit complements of positive numbers –+9 on 8 bits = –-9 on 8 bits = Range [-2 n-1 -1, +2 n-1 -1] –8 bits: [-127, +127] –12 bits: [-2047, +2047] Advantages –Easy Representation –Easier arithmetic operations (add/sub) than sign + magnitude Disadvantages –Has the problem of double representing the 0 (–0 and +0), –Add/Sub still relatively complex Examples: – – 0001

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 12 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Two’s Complement Range [-2 n-1, +2 n-1 -1] –8 bits: [-128, +127] –12 bits: [-2048, +2047] Advantages –No double representation of 0 (the 2's complement of 0 is still 0), –Simplest Add/Subtract circuit design, –Add/Subtract operations is done in one-step, –The end result is already represented in 2's complement (not when overflow). Negative number represented as bit to bit complement of positive number plus 1 Coming from: x + (-x) = 0 Given x + x = -1 (check for any number)

King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department College of Computer Science And Engineering College of Computer Science And Engineering Lecture 5 – Data Representation 13 © 2005 Dr. Abdelhafid Bouhraoua COE 205 Character Representation ASCII –Broadly Used –Standard –Limited in representing other languages –7 bits + 1 bit (parity) Even Parity: put 1 in PB if # of 1s is even Odd Parity: put 1 in PB if # of 1s is odd Unicode –16 bits –Used to represent chars of all languages