1 Data Representation Computer Organization Prof. H. Yoon DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations.

Slides:



Advertisements
Similar presentations
A digital system is a system that manipulates discrete elements of information represented internally in binary form. Digital computers –general purposes.
Advertisements

Chapter 1 Binary Systems 1-1. Digital Systems
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Number Systems Standard positional representation of numbers:
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Overflow Signed binary is in fixed range -2 n-1  2 n-1 If the answer for addition/subtraction more than the.
Number Systems Lecture 02.
1.6 Signed Binary Numbers.
Dr. Bernard Chen Ph.D. University of Central Arkansas
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Data Representation – Binary Numbers
The character data type char
Computers Organization & Assembly Language
Digital Design: From Gates to Intelligent Machines
Decimal Binary Octal Hex
Chap. 3 Data Representation
Dept. of Computer Science Engineering Islamic Azad University of Mashhad 1 DATA REPRESENTATION Dept. of Computer Science Engineering Islamic Azad University.
Eng. Mohammed Timraz Electronics & Communication Engineer University of Palestine Faculty of Engineering and Urban planning Software Engineering Department.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Number Systems Spring Semester 2013Programming and Data Structure1.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Lecture 4: Number Systems (Chapter 3) (1) Data TypesSection3-1 (2) ComplementsSection3-2 (3) Fixed Point RepresentationsSection3-3 (4) Floating Point RepresentationsSection3-4.
Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7× × × ×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10.
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.
CE1111 :Digital Logic Design lecture 01 Introduction Dr. Atef Ali Ibrahim.
Figure 1.1 Block diagram of a digital computer. Functional Units.
Number Systems and Codes. CS2100 Number Systems and Codes 2 NUMBER SYSTEMS & CODES Information Representations Number Systems Base Conversion Negative.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
CS311-Computer OrganizationInformation RepresentationLecture 03-1 Lecture 3 Information Representation.
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
1 Information Representation in Computer Lecture Nine.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
CS 2130 Lecture 23 Data Types.
Chapter 1: Binary Systems
Systems Architecture, Fourth Edition 1 Data Representation Chapter 3.
NUMBER SYSTEMS AND CODES. CS Digital LogicNumber Systems and Codes2 Outline Number systems –Number notations –Arithmetic –Base conversions –Signed.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
DATA REPRESENTATION Data Types Complements Fixed Point Representations
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.
PRIMITIVE TYPES IN JAVA Primitive Types Operations on Primitive Types.
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.
Chapter 1 Digital Systems and Binary Numbers
Data Representation COE 308 Computer Architecture
Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations
Lec 3: Data Representation
Data Representation.
Number Representation
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Chapter 2 Data Types and Representations
Chapter 1 Digital Systems and Binary Numbers
CS1010 Programming Methodology
Javascript, Loops, and Encryption
Data Representation Data Types Complements Fixed Point Representation
Digital Logic & Design Lecture 03.
ASCII Character Codes nul soh stx etx eot 1 lf vt ff cr so
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Cosc 2P12 Week 2.
Number Systems Lecture 2.
Introduction to Computer Engineering
DATA REPRESENTATION Data Types Complements Fixed Point Representations
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Cosc 2P12 Week 2.
Data Representation COE 308 Computer Architecture
Chapter 2 Bits, Data Types, and Operations
Presentation transcript:

1 Data Representation Computer Organization Prof. H. Yoon DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations Other Binary Codes Error Detection Codes

2 Data Representation Computer Organization Prof. H. Yoon DATA REPRESENTATION Information that a Computer is dealing with * Data - Numeric Data Numbers( Integer, real) - Non-numeric Data Letters, Symbols * Relationship between data elements - Data Structures Linear Lists, Trees, Rings, etc * Program(Instruction) Data Types

3 Data Representation Computer Organization Prof. H. Yoon NUMERIC DATA REPRESENTATION R = 10 Decimal number system,R = 2 Binary R = 8 Octal,R = 16 Hexadecimal Radix point(.) separates the integer portion and the fractional portion Data Numeric data - numbers(integer, real) Non-numeric data - symbols, letters Number System Nonpositional number system - Roman number system Positional number system - Each digit position has a value called a weight associated with it - Decimal, Octal, Hexadecimal, Binary Base (or radix) R number - Uses R distinct symbols for each digit - Example A R = a n-1 a n-2... a 1 a 0.a -1 …a -m - V(A R ) = Data Types

4 Data Representation Computer Organization Prof. H. Yoon WHY POSITIONAL NUMBER SYSTEM IN DIGITAL COMPUTERS ? Major Consideration is the COST and TIME - Cost of building hardware Arithmetic and Logic Unit, CPU, Communications - Time to processing Arithmetic - Addition of Numbers - Table for Addition * Non-positional Number System - Table for addition is infinite --> Impossible to build, very expensive even if it can be built * Positional Number System - Table for Addition is finite --> Physically realizable, but cost wise the smaller the table size, the less expensive --> Binary is favorable to Decimal Binary Addition Table Decimal Addition Table Data Types

5 Data Representation Computer Organization Prof. H. Yoon REPRESENTATION OF NUMBERS - POSITIONAL NUMBERS Decimal Binary Octal Hexadecimal A B C D E F Binary, octal, and hexadecimal conversion A F 6 3 Octal Binary Hexa Data Types

6 Data Representation Computer Organization Prof. H. Yoon CONVERSION OF BASES Decimal to Base R number Base R to Decimal Conversion V(A) =  a k  R k A = a n-1 a n-2 a n-3 … a 0. a -1 … a -m (736.4) 8 = 7 x x x x 8 -1 = 7 x x x 1 + 4/8 = (478.5) 10 (110110) 2 =... = (54) 10 ( ) 2 =... = (6.785) 10 (F3) 16 =... = (243) 10 (0.325) 6 =... = ( ) 10 - Separate the number into its integer and fraction parts and convert each part separately. - Convert integer part into the base R number → successive divisions by R and accumulation of the remainders. - Convert fraction part into the base R number → successive multiplications by R and accumulation of integer digits Data Types

7 Data Representation Computer Organization Prof. H. Yoon EXAMPLE Convert to base 2. Integer = Fraction = x x x x (41) 10 = (101001) 2 (0.6875) 10 = (0.1011) 2 ( ) 10 = ( ) 2 Convert (63) 10 to base 5: (223) 5 Convert (1863) 10 to base 8: (3507) 8 Convert ( ) 10 to hexadecimal: (0.A3) 16 Exercise Data Types

8 Data Representation Computer Organization Prof. H. Yoon COMPLEMENT OF NUMBERS Two types of complements for base R number system: - R's complement and (R-1)'s complement The (R-1)'s Complement Subtract each digit of a number from (R-1) Example - 9's complement of is 's complement of is (bit by bit complement operation) The R's Complement Add 1 to the low-order digit of its (R-1)'s complement Example - 10's complement of is = 's complement of is = Complements

9 Data Representation Computer Organization Prof. H. Yoon FIXED POINT NUMBERS Binary Fixed-Point Representation X = x n x n-1 x n-2... x 1 x 0. x -1 x x -m Sign Bit(x n ): 0 for positive ; 1 for negative Remaining Bits(x n-1 x n-2... x 1 x 0. x -1 x x -m ) Numbers:Fixed Point Numbers and Floating Point Numbers Fixed Point Representations

10 Data Representation Computer Organization Prof. H. Yoon SIGNED NUMBERS Signed magnitude representation Signed 1's complement representation Signed 2's complement representation Example: Represent +9 and -9 in 7 bit-binary number Only one way to represent +9 ==> Three different ways to represent -9: In signed-magnitude: In signed-1's complement: In signed-2's complement: In general, in computers, fixed point numbers are represented either integer part only or fractional part only. Need to be able to represent both positive and negative numbers - Following 3 representations

11 Data Representation Computer Organization Prof. H. Yoon CHARACTERISTICS OF 3 DIFFERENT REPRESENTATIONS Complement Signed magnitude:Complement only the sign bit Signed 1's complement:Complement all the bits including sign bit Signed 2's complement:Take the 2's complement of the number, including its sign bit. Maximum and Minimum Representable Numbers and Representation of Zero X = x n x n-1... x 0. x x -m Signed Magnitude Max: 2 n - 2 -m Min: -(2 n - 2 -m ) Zero: Signed 1’s Complement Max: 2 n - 2 -m Min: -(2 n - 2 -m ) Zero: Fixed Point Representations Signed 2’s Complement Max: 2 n - 2 -m Min: -2 n Zero:

12 Data Representation Computer Organization Prof. H. Yoon 2’s COMPLEMENT REPRESENTATION WEIGHTS Signed 2’s complement representation follows a “weight” scheme similar to that of unsigned numbers –Sign bit has negative weight –Other bits have regular weights X = x n x n-1... x 0  V(X) = - x n  2 n +  x i  2 i i = 0  n-1

13 Data Representation Computer Organization Prof. H. Yoon ARITHMETIC ADDITION: SIGNED MAGNITUDE [1] Compare their signs [2] If two signs are the same, ADD the two magnitudes - Look out for an overflow [3] If not the same, compare the relative magnitudes of the numbers and then SUBTRACT the smaller from the larger --> need a subtractor to add [4] Determine the sign of the result ) > ) > ) > ) > (- 9) -6 + (-9) Overflow or (-9) + (-9) ) (1)0010 overflow Fixed Point Representations

14 Data Representation Computer Organization Prof. H. Yoon ARITHMETIC ADDITION: SIGNED 2’s COMPLEMENT Example (1) Add the two numbers, including their sign bit, and discard any carry out of leftmost (sign) bit - Look out for an overflow overflow ) operands have the same sign and the result sign changes x n-1 y n-1 s’ n-1 + x’ n-1 y’ n-1 s n-1 = c n-1  c n x’ n-1 y’ n-1 s n-1 (c n-1  c n ) x n-1 y n s’ n-1 (c n-1  c n ) Fixed Point Representations

15 Data Representation Computer Organization Prof. H. Yoon ARITHMETIC ADDITION: SIGNED 1’s COMPLEMENT Add the two numbers, including their sign bits. - If there is a carry out of the most significant (sign) bit, the result is incremented by 1 and the carry is discarded (1) 0(1) ) end-around carry (1) ) (1)0010 +) overflow Example not overflow (c n-1  c n ) = 0 (c n-1  c n ) Fixed Point Representations

16 Data Representation Computer Organization Prof. H. Yoon COMPARISON OF REPRESENTATIONS * Easiness of negative conversion S + M > 1’s Complement > 2’s Complement * Hardware - S+M: Needs an adder and a subtractor for Addition - 1’s and 2’s Complement: Need only an adder * Speed of Arithmetic 2’s Complement > 1’s Complement(end-around C) * Recognition of Zero 2’s Complement is fast Fixed Point Representations

17 Data Representation Computer Organization Prof. H. Yoon ARITHMETIC SUBTRACTION Take the complement of the subtrahend (including the sign bit) and add it to the minuend including the sign bits. (  A ) - ( - B ) = (  A ) + B (  A ) - B = (  A ) + ( - B ) Fixed Point Representations Arithmetic Subtraction in 2’s complement

18 Data Representation Computer Organization Prof. H. Yoon FLOATING POINT NUMBER REPRESENTATION * The location of the fractional point is not fixed to a certain location * The range of the representable numbers is wide F = EM m n e k e k-1... e 0 m n-1 m n-2 … m 0. m -1 … m -m sign exponent mantissa - Mantissa Signed fixed point number, either an integer or a fractional number - Exponent Designates the position of the radix point Decimal Value V(F) = V(M) * R V(E) M: Mantissa E: Exponent R: Radix Floating Point Representation

19 Data Representation Computer Organization Prof. H. Yoon FLOATING POINT NUMBERS sign mantissaexponent ==> x Example A binary number in 16-bit floating point number representation (6-bit exponent and 10-bit fractional mantissa) Example Note: In Floating Point Number representation, only Mantissa(M) and Exponent(E) are explicitly represented. The Radix(R) and the position of the Radix Point are implied. ExponentMantissaSign or Floating Point Representation

20 Data Representation Computer Organization Prof. H. Yoon CHARACTERISTICS OF FLOATING POINT NUMBER REPRESENTATIONS Normal Form - There are many different floating point number representations of the same number → Need for a unified representation in a given computer - the most significant position of the mantissa contains a non-zero digit Representation of Zero - Zero Mantissa = 0 - Real Zero Mantissa = 0 Exponent = smallest representable number which is represented as  Easily identified by the hardware Floating Point Representation

21 Data Representation Computer Organization Prof. H. Yoon INTERNAL REPRESENTATION AND EXTERNAL REPRESENTATION CPU Memory Internal Representation Human Device Another Computer External Representation External Representation External Representation

22 Data Representation Computer Organization Prof. H. Yoon EXTERNAL REPRESENTATION Decimal BCD Code Numbers Most of numbers stored in the computer are eventually changed by some kinds of calculations → Internal Representation for calculation efficiency → Final results need to be converted to as External Representation for presentability Alphabets, Symbols, and some Numbers Elements of these information do not change in the course of processing → No needs for Internal Representation since they are not used for calculations → External Representation for processing and presentability Example Decimal Number: 4-bit Binary Code BCD(Binary Coded Decimal) External Representations

23 Data Representation Computer Organization Prof. H. Yoon OTHER DECIMAL CODES Decimal BCD(8421) Excess d 3 d 2 d 1 d 0 : symbol in the codes BCD: d 3 x 8 + d 2 x 4 + d 1 x 2 + d 0 x 1  8421 code. 2421: d 3 x 2 + d 2 x 4 + d 1 x 2 + d 0 x : d 3 x 8 + d 2 x 4 + d 1 x (-2) + d 0 x (-1) Excess-3: BCD + 3 Note: 8,4,2,-2,1,-1 in this table is the weight associated with each bit position. BCD: It is difficult to obtain the 9's complement. However, it is easily obtained with the other codes listed above. → Self-complementing codes External Representations

24 Data Representation Computer Organization Prof. H. Yoon GRAY CODE * Characterized by having their representations of the binary integers differ in only one digit between consecutive integers * Useful in some applications Decimal number Gray Binary g 3 g 2 g 1 g 0 b 3 b 2 b 1 b bit Gray codes Other Binary codes

25 Data Representation Computer Organization Prof. H. Yoon GRAY CODE - ANALYSIS Letting g n g n-1... g 1 g 0 be the (n+1)-bit Gray code for the binary number b n b n-1... b 1 b 0 g i = b i  b i+1, 0  i  n-1 g n = b n and b n-i = g n  g n-1 ...  g n-i b n = g n The Gray code has a reflection property - easy to construct a table without calculation, - for any n: reflect case n-1 about a mirror at its bottom and prefix 0 and 1 to top and bottom halves, respectively Reflection of Gray codes Note: Other Binary codes 

26 Data Representation Computer Organization Prof. H. Yoon CHARACTER REPRESENTATION ASCII ASCII (American Standard Code for Information Interchange) Code Other Binary codes ABCDEF ABCDEF NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI SP ! “ # $ % & ‘ ( ) * +, -. / :;<=>? :;<=>? PQRSTUVWXYZ[\]^_PQRSTUVWXYZ[\]^_.abcdefghIjklmno.abcdefghIjklmno p q r s t u v w x y z { | } ~ DEL DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US LSB (4 bits) MSB (3 bits)

27 Data Representation Computer Organization Prof. H. Yoon CONTROL CHARACTER REPRESENTAION (ACSII) NUL Null SOH Start of Heading (CC) STX Start of Text (CC) ETX End of Text (CC) EOT End of Transmission (CC) ENQ Enquiry (CC) ACK Acknowledge (CC) BEL Bell BS Backspace (FE) HT Horizontal Tab. (FE) LF Line Feed (FE) VT Vertical Tab. (FE) FF Form Feed (FE) CR Carriage Return (FE) SO Shift Out SI Shift In DLE Data Link Escape (CC) (CC) Communication Control (FE) Format Effector (IS) Information Separator Other Binary codes DC1 Device Control 1 DC2 Device Control 2 DC3 Device Control 3 DC4 Device Control 4 NAK Negative Acknowledge (CC) SYN Synchronous Idle (CC) ETB End of Transmission Block (CC) CAN Cancel EM End of Medium SUB Substitute ESC Escape FS File Separator (IS) GS Group Separator (IS) RS Record Separator (IS) US Unit Separator (IS) DEL Delete

28 Data Representation Computer Organization Prof. H. Yoon ERROR DETECTING CODES Parity System - Simplest method for error detection - One parity bit attached to the information - Even Parity and Odd Parity Even Parity - One bit is attached to the information so that the total number of 1 bits is an even number Odd Parity - One bit is attached to the information so that the total number of 1 bits is an odd number Error Detecting codes

29 Data Representation Computer Organization Prof. H. Yoon Parity Bit Generation For b 6 b 5... b 0 (7-bit information); even parity bit b even b even = b 6  b 5 ...  b 0 For odd parity bit b odd = b even  1 = b even PARITY BIT GENERATION

30 Data Representation Computer Organization Prof. H. Yoon PARITY GENERATOR AND PARITY CHECKER Parity Generator Circuit (even parity) b6b5b4b3b2b1b0b6b5b4b3b2b1b0 b even Parity Checker b6b5b4b3b2b1b0b6b5b4b3b2b1b0 b even Even Parity error indicator Error Detecting codes