Lecture 4: Number Systems (Chapter 3) (1) Data TypesSection3-1 (2) ComplementsSection3-2 (3) Fixed Point RepresentationsSection3-3 (4) Floating Point RepresentationsSection3-4.

Slides:



Advertisements
Similar presentations
COE 202: Digital Logic Design Signed Numbers
Advertisements

King Fahd University of Petroleum and Minerals
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Data Representation Computer Organization &
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Data Representation COE 205
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
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
Number Systems Lecture 02.
Binary Number Systems.
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.
Simple Data Type Representation and conversion of numbers
1 Data Representation Computer Organization Prof. H. Yoon DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations.
Data Representation – Binary Numbers
Computers Organization & Assembly Language
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.
IT253: Computer Organization
Computer Architecture
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.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
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.
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.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Operations on Bits Arithmetic Operations Logic Operations
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
1 Information Representation in Computer Lecture Nine.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
CS 2130 Lecture 23 Data Types.
Systems Architecture, Fourth Edition 1 Data Representation Chapter 3.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Programming for GCSE Topic 2.2: Binary Representation T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
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.
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.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations
Lec 3: Data Representation
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Chapter 2 Data Types and Representations
Chapter 2 Bits, Data Types, and Operations
Data Representation Data Types Complements Fixed Point Representation
Chapter 2 Bits, Data Types, and Operations
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Cosc 2P12 Week 2.
Number Systems Lecture 2.
School of Computer Science and Technology
Introduction to Computer Engineering
DATA REPRESENTATION Data Types Complements Fixed Point Representations
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Cosc 2P12 Week 2.
Chapter 2 Bits, Data Types, and Operations
Presentation transcript:

Lecture 4: Number Systems (Chapter 3) (1) Data TypesSection3-1 (2) ComplementsSection3-2 (3) Fixed Point RepresentationsSection3-3 (4) Floating Point RepresentationsSection3-4 (5) Other Binary CodesSection3-5 (6) Error Detection CodesSection3-6

Data Types 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 (Instructions)

Data Types: Numeric Data Representation Nonpositional number system Roman number system Positional number system Each digit position has a value called a weight associated with it Examples: 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 ) = SUM (a k * R k )for k = -m to n-1 R = 10Decimal number system R = 2Binary R = 8Octal R = 16Hexadecimal

Data Types: Numeric Data Representation Why a Positional Number System for 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

Unsigned binary numbers are typically used to represent computer addresses or other values that are guaranteed not to be negative. An n-bit unsigned binary integer A = a n-1 a n-2... a 1 a 0 has a value of For example, 1011 = 1 x x x x 2 0 = = 11 An n-bit unsigned binary integer has a range from 0 to 2 n - 1. Positive (Unsigned) Binary Numbers

Octal and Hexadecimal Numbers Octal, base-8, numbers were used in the early days of computing to represent binary numbers Octal numbers are made by grouping binary numbers together three bits at a time Hexadecimal, base-16, numbers are the representation of choice today Hex numbers are made by grouping binary numbers together four bits at a time For example: Octal: Binary: Hex:E A 9 F 5 2

Negative (Signed) Binary Numbers Positional representation using n bits X = X n X n-1 X n-2 … X 1 X 0. X -1 X X -m Sign-magnitude format Left most bit position (X n ) is the sign bit -- only bit that is complemented 0 for positive number 1 for negative number Remaining n-1 bits represent the magnitude Min:- (2 n - 2 -m )= Max:+ (2 n - 2 -m )= Zero:- 0= Zero:+0=

Complements of Numbers Two types of complements for base R number system: R’s complement(R-1)’s complement The (R-1)’s Complement Subtract each digit of a number from (R-1) Examples: 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 Examples: 10’s complement of is = ’s complement of is =

Negative (Signed) Binary Numbers Ones complement format Negative numbers are represented by a bit-by-bit complementation of the (positive) magnitude (the process of negation) Sign bit interpreted as in sign-magnitude format Examples (8-bit words): +42= = Min:- (2 n - 2 -m )= Max:+ (2 n - 2 -m )= Zero:- 0= Zero:+0=

Negative (Signed) Binary Numbers Twos complement format Negative numbers, -X, are represented by the pseudo- positive number:2 n - |X| An n-bit unsigned binary integer A = a n-1 a n-2... a 1 a 0 has a value of For example:1011= -1 x x x x 2 0 = = -5 With 2 n digits: 2 n-1 -1 positive numbers 2 n -1 negative numbers Given the representation for +X, the representation for -X is found by taking the 1s complement of +X and adding 1

Negative (Signed) Binary Numbers Twos complement format Most significant bit is the “sign bit”. Number representation is not symmetric. Only one representation for zero. Easy to negate, add, and subtract numbers. A little bit trickier for multiply and divide. Min:- (2 n )= Max:+ (2 n - 2 -m )= Zero:=

Signed 2’s Complement Addition Add the two numbers, including their sign bit, and discard any carry out of left-most(sign) bit Examples: = = = (1)

Detecting 2’s Complement Overflow When adding two's complement numbers, overflow will only occur if the numbers being added have the same sign the sign of the result is different If we perform the addition a n-1 a n-2... a 1 a 0 + b n-1 b n-2 … b 1 b = s n-1 s n-2 … s 1 s 0 Overflow can be detected as where c n-1 and c n are the carry in and carry out of the most significant bit.

Signed 2’s Complement Subtraction To subtract two's complement numbers we first negate the second number and then add the corresponding bits of both numbers. Examples: 3 = = = = = = = = 1110 become: 3 = = = = = = = = = = = = 0101

Sign-Extension / Zero-Extension Sign-extension is used for signed immediates and signed values from memory To sign-extend an n bit number to n+m bits, copy the sign-bit m times. For example, with n = 4 and m = 4, 1011 = = = = 5 Zero-extension is used for logical operations and unsigned values from memory To zero-extend an n bit number to n+m bits, copy zero m times. For example, with n = 4 and m = 4, 1011 = = = = 5

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 --> high precision F = EM m n e k e k-1... e 0 m n-1 m n-2... m 0. m 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

Floating Point Number Representation Decimal Value: V = M * R E Where: M= Mantissa E= Exponent R= Radix (10) Example (decimal): ExponentMantissa SignValueSignValue ==> x 10 +4

Floating Point Number Representation Example (binary): (= 9.75) Make a fractional number, counting the number of shifts: ==> 4 shifts ExponentMantissa SignValueSignValue Or for a 16-bit number with a sign, 5-bit exponent, 10-bit mantissa:

Other Representations- Gray Codes Characterized by having their representations of the binary integers different in only one digit between consecutive integers Useful in analog-digital conversion. DecimalGray BinaryDecimalGrayBinary

Other Representations- ASCII Characters 4MSBs 3LSBs (hex)NUL DLE SP P ‘ p 1SOH DC1 ! 1A Qaq 2STX DC2 " 2B Rbr 3ETX DC3 # 3C Scs 4EOT DC4 $ 4D Tdt 5ENQ NAK % 5E Ueu 6ACK SYN & 6FVfv 7BEL ETB ’ 7GWgw 8BS CAN (8HXhx 9HT EM ) 9IYiy ALF SUB * :JZjz BVT ESC + ; K[k{ CFF FS, <L\l| DCR GS - =M]m} ESO RS. >N^n~ FSI US / ? O_oDEL

Error Detecting Codes- Parity 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 ==> B even = B n-1 (+) B n-2 (+) … B 0 Odd Parity One bit is attached to the information so that the total number of 1 bits is an odd number ==> B odd = B n-1 (+) B n-2 (+) … B 0 (+) 1

Error Detecting Codes- Parity B 0 B 1 B 2 B 3 B 4 B 5 B 6 B even B 0 B 1 B 2 B 3 B 4 B 5 B 6 B even ERROR Even Parity Generator Circuit Even Parity Checker Circuit