AEEE2031 Data Representation and Numbering Systems.

Slides:



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

DATA REPRESENTATION CONVERSION.
Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
Chapter 1 Digital Systems and Numbers System
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
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
Digital Fundamentals Floyd Chapter 2 Tenth Edition
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
1 Number Systems. 2 Numbers Each number system is associated with a base or radix – The decimal number system is said to be of base or radix 10 A number.
Number Systems and Arithmetic
Dr. Bernard Chen Ph.D. University of Central Arkansas
Binary and Hexadecimal Numbers
© 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.
Numeral Systems Subjects: Numeral System Positional systems Decimal
Data Representation – Binary Numbers
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Numbering Systems CS208.
#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.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
مدار منطقي مظفر بگ محمدي Course Structure & Grading Homework: 25% Midterm: 30% Final:50% There is 5% extra! ( =105!) Textbook:
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.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
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.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
Number systems, Operations, and Codes
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
Computer Math CPS120 Introduction to Computer Science Lecture 4.
1 Review on Number Systems Decimal, Binary, and Hexadecimal.
Number Systems & Operations
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
1 Number Systems Decimal, Binary, and Hexadecimal.
CPEN Digital Logic Design Binary Systems Spring 2004 C. Gerousis © Digital Design 3 rd Ed., Mano Prentice Hall.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Introduction to Digital Electronics Lecture 2: Number Systems.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
Computer Math CPS120 Introduction to Computer Science Lecture 7.
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.
Digital logic COMP214  Lecture 2 Dr. Sarah M.Eljack Chapter 1 1.
Data Representation COE 308 Computer Architecture
Number Systems & Binary Arithmetic
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
CHAPTER 1 : INTRODUCTION
Number Systems.
COMPUTING FUNDAMENTALS
Chapter 3 Data Representation
Number System conversions
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
University of Gujrat Department of Computer Science
Data Representation COE 301 Computer Organization
MMNSS COLLEGE,KOTTIYAM DEPARTMENT OF PHYSICS
Digital Electronics & Logic Design
Numbering System TODAY AND TOMORROW 11th Edition
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Data Representation ICS 233
Number Systems Rayat Shikshan Sanstha’s
Data Representation COE 308 Computer Architecture
Presentation transcript:

AEEE2031 Data Representation and Numbering Systems

AEEE2032 The Decimal Numbering System In the Decimal system a digit can take one out of ten different values (0..9) A number in the decimal system is expressed by the following expression: Notes: –A decimal system with N digits can represent the numbers from 0 to 10 N -1. –In a decimal system with N digits there are 10 N different combinations. –The digit to the right of a number is called the Least Significant Digit (LSD). –The digit to the left of a number is called the Most Significant Digit (MSD). (d n d n-1 …d 1 d 0 ) 10 = (d n X 10 n )+ (d n-1 X 10 n-1 ) + …+ (d 1 X 10 1 ) +( d 0 X 10 0 ) Where d = {0,1,2,3,4,5,6,7,8,9} = {0..9}

AEEE2033 The Binary Numbering System Digital systems and computers use the Binary system because it has only two states (0 and 1) A number in the Binary system is expressed by the following expression: Examples: (1011) 2 = (1 X 2 3 )+(0 X 2 2 )+(1 X 2 1 ) +(1 X 2 0 ) = = (11) 10 (10110) 2 = (1 X 2 4 )+(0 X 2 3 )+(1 X 2 2 ) +(1 X 2 1 ) +(0 X 2 0 ) = = (22) 10 (101100) 2 =(1 X 2 5 )+(0 X 2 4 )+(1 X 2 3 )+(1 X 2 2 )+(0 X 2 1 )+(0 X 2 0 )= =(44) 10 (d n d n-1 …d 1 d 0 ) 2 = (d n X 2 n )+ (d n-1 X 2 n-1 ) + …+ (d 1 X 2 1 ) +( d 0 X 2 0 ) Where d = {0,1}

AEEE2034 The Binary Numbering System (Cont.) A binary digit is called the BIT (BInary digiT). A group of eight bits is called the BYTE. The leftmost bit of a number is called the Most Significant Bit (MSB). The rightmost bit of a number is called the Least Significant Bit (LSB). A binary system with N bits can represent the numbers from 0 to 2 N -1. In a binary system with N digits there are 2 N different combinations. A binary number is multiplied by two, if we append a zero at the LSB. Prefixes in the binary system: 2 10 = 1,024 = 1K (Kilo) 2 20 = 1,024 X 1,024 = 1,048,576 = 1M (Mega) 2 30 = 1G (Giga) 2 40 = 1T (Tera) Powers of 2: 2 0 = = = = = = = = = = =1024=1K 2 16 = 65536

AEEE2035 A General Numbering System With Base R A numbering system with base R can have digits in the range from 0 to R-1 A number in a system with base R is expressed by the following expression: Examples: A computer that uses light (color) to represent information will use a numbering system with a base of 3, since there are three basic colors. Usually in computers we group the bit of a number for simplicity. A group of 4 bits yields a system with 16 combinations. Such a system is called the Hexadecimal system (d n d n-1 …d 1 d 0 ) R = (d n X R n )+ (d n-1 X R n-1 ) + …+ (d 1 X R 1 ) +( d 0 X R 0 ) Where d = {0.. R - 1}

AEEE2036 Conversion from a system with base R to Decimal To convert a number from a system with base R to decimal we replace R with the base of the system in the following expression: Examples: (214) 5 = (2 X 5 2 )+(1 X 5 1 ) +(4 X 5 0 ) = (2 X 25)+(1 X 5)+(4 X 1)=50+5+4= (59) 10 (2021) 3 = (2 X 3 3 )+(0 X 3 2 )+(2 X 3 1 )+(1 X 3 0 )=(2 X 27)+(2 X 3)+(1 X 1)=54+6+1= (61) 10 (13A) 12 = (1 X 12 2 )+(3 X 12 1 )+(10 X 12 0 )= =(190) 10 (4C) 18 = (4 X 18 1 )+(12 X 18 0 )=72+12=(84) 10 (135) 4 = Invalid. Digit 5 is greater than 4 which is the base of the system. (d n d n-1 …d 1 d 0 ) R = (d n X R n )+ (d n-1 X R n-1 ) + …+ (d 1 X R 1 ) +( d 0 X R 0 )

AEEE2037 Examples Do the following conversions: (234) 6 = (?) 10 (2012) 3 = (?) 10 (A1C) 14 = (?) 10 (5H) 20 = (?) 10 (122) 4 = (?) 10 (1220) 4 = (?) 10 (12200) 4 = (?) 10 (122003) 4 = (?) 10

AEEE2038 Conversion from Decimal to a system with base R A decimal number can be converted into its equivalent in base R using the following procedure: Step 1:Perform the integer division of the decimal number by R and record the remainder. e.g. if the number is 70 and the base is 4 then 70/4 = /4 Step 2:Replace the decimal number with the result of the division in step 1. Repeat step 1, until a zero result is found. e.g. 17/4 = 4 + 1/4 4/4 = 1 + 0/4 1/4 = 0 + 1/4 Step 3:The number is formed by reading the remainders in reversed order. e.g.(70) 10 = (1012) 4

AEEE2039 Examples Do the following conversions: (53) 10 = (?) 2 (47) 10 = (?) 3 (124) 10 = (?) 14 (253) 10 = (?) 20 (97) 10 = (?) 7 (25) 10 = (?) 4 (250) 10 = (?) 4 (100) 10 = (?) 4

AEEE20310 Homework: Do the necessary conversions to fill up the table below:

AEEE20311 Homework Do the following conversions: (244) 5 = (?) 10 (2132) 4 = (?) 10 (A4F) 18 = (?) 10 (6H) 22 = (?) 10 (1202) 3 = (?) 10 (12020) 3 = (?) 10 (120200) 3 = (?) 10 ( ) 4 = (?) 10

AEEE20312 The Octal and Hexadecimal Numbering Systems Computers use the binary system to represent data. In most cases a number is represented with 16, 32 or more bits, which is difficult to be handled by humans. To make binary numbers easier to manipulate, we can group the bits of the number in groups of 2, 3 or 4 bits. If we take a group of 2 bits, then we can have 4 combinations or different digits in each group. Thus the new system is a system with the base of 4. e.g. ( ) 2 = ( ) 2 = (2310) 4 The system with the base 4 is not widely used because many digits are still required to represent typical numbers. (10) 2 = 2 (01) 2 = 1 (11) 2 = 3(00) 2 = 0

AEEE20313 The Octal and Hexadecimal Numbering Systems (Cont.) If we take a group of 3 bits, then we can have 8 combinations or different digits in each group. Thus the new system is a system with the base of 8 and is called the Octal system. e.g. ( ) 2 = ( ) 2 = (264) 8 If we take a group of 4 bits, then we can have 16 combinations or different digits in each group. Thus the new system is a system with the base of 16and is called the hexadecimal or hex system. Letters A to F are used to represent digits from 10 to 15. e.g. ( ) 2 = ( ) 2 = (B4) 16 (010) 2 = 2 (100) 2 = 4 (110) 2 = 6 (1011) 2 =11=B (0100) 2 = 4

AEEE20314 Decimal, Binary, Octal and Hexadecimal Conversion Table DecimalBinaryBase 4Octal Hex A B C D E F

AEEE20315 Examples

AEEE20316 Homework Do the following conversions: (53) 10 = (?) 2 = (?) 4 = (?) 8 = (?) 16 ( ) 2 = (?) 10 = (?) 4 = (?) 8 = (?) 16 (1203) 4 = (?) 10 = (?) 2 = (?) 8 = (?) 16 (253) 8 = (?) 10 = (?) 2 = (?) 4 = (?) 16 (9C) 16 = (?) 2 = (?) 4 = (?) 8 = (?) 10

AEEE20317 Fractional number representation Let us assume a radix point (.) with the decimal part on the left and the fractional part on the right Then Example:

AEEE20318 Examples (2B.1A)

AEEE20319 Converting fractional numbers from decimal number system to radix r To convert a decimal fraction to a radix r number, repeatedly multiply the fraction part by r and retain the integer digit in sequence until the fraction is zero, or the number of digits required are obtained (the number of digits may be infinite). Then the digits following the radix point from left to right with the integer digits, the earliest obtained first.

AEEE20320 Example  2 = Most significant  2 =  2 =  2 = Least significant

AEEE20321 Converting fractional numbers from from binary to hex and from hex to binary The same principle with integer numbers applies: Group four bits together, padding with zeros if necessary, but this time from left to right, and convert its 4-bit group to its corresponding Hexadecimal number and vice versa Examples:

AEEE20322 Homework

AEEE20323 The Binary Coded Decimal (BCD) System In many applications it is required to encode each decimal digit to the equivalent 4-bit binary number. This binary code is called the BCD code. e.g. (2 4 9) 10 = ( ) BCD Examples: (173) 10 = (?) 2 = (?) BCD ( ) BCD = (?) 10 ( ) 2 = (?) BCD (53) 16 = (?) BCD ( ) BCD = (?) 10 2 =(0010) 2 9 = (1001) 2 4 =(0100) 2

AEEE20324 Addition in any numbering system Addition in any numbering system can be performed by following the same rules used for decimal addition, where 10 is replaced by the base of the system (R). Decimal Addition: Rules for addition in the decimal system: –Begin the addition by adding the 2 least significant digits first. –Perform the integer division of the sum with 10. Write down the remainder of the division and carry out the result to the next column. –Repeat the addition for the next columns by adding the two digits and the carry from the previous column = 9  9/10 = 0 + 9/10  write 9 and carry = 9  9/10 = 0 + 9/10  write 9 and carry = 12  12/10 = 1 + 2/10  write 2 and carry 1

AEEE20325 Addition in any numbering system Rules for addition in a system with base R: –Begin the addition by adding the 2 least significant digits first. –Perform the integer division of the sum with R. Write down the remainder of the division and carry out the result to the next column. –Repeat the addition for the next columns by adding the two digits and the carry from the previous column. Examples: Perform the following additions (173) 8 + (265) 8 = (?) 8 ( ) 2 + ( ) 2 = (?) 2 (1243) 5 + (234) 5 = (?) 5 (1A79) 16 + (C827) 16 = (?) 16 (1A79) 18 + (C827) 18 = (?) 18

AEEE20326 Subtraction in any numbering system Subtraction in any numbering system can be performed by following the same rules used for decimal addition, where 10 is replaced by the base of the system (R). Decimal Subtraction: Rules for subtraction in the decimal system: –Begin the subtraction from 2 least significant digits first. –If the minuend is greater than the subtrahend then perform the subtraction. –If the minuend is less than the subtrahend then borrow 1 from the next column. Write down the result of (minuend subtrahend). The one borrowed must be subtracted from the minuend of the next column. –Repeat the subtraction for the next columns. (7-1  1)  = 5  write 5 and borrow 0 from next column (9  6)  = 3  write 3 and borrow 0 from next column (4<8)  borrow 1  =6  write 6 and borrow 1 from next column

AEEE20327 Subtraction in any numbering system Rules for subtraction in a system with base R: The rules for subtraction in a system with base R are the same as in decimal, except that a borrow into a given column adds R units to the minuend digit. Examples: Perform the following subtractions: (476) 10 - (285) 10 = (?) 10 (285) 10 - (476) 10 = (?) 10 (173) 8 - (265) 8 = (?) 8 ( ) 2 - ( ) 2 = (?) 2 (423) 5 - (234) 5 = (?) 5 (61A9) 16 - (C827) 16 = (?) 16 (61A9) 18 - (C827) 18 = (?) 18

AEEE20328 Subtraction using the complement’s method In the previous examples, the subtraction {(285) 10 - (476) 10 } give a result equal to 809. The correct result is If we examine carefully the subtraction we can observe that the subtraction of the last digit was carried out using a borrow, i.e. the result 809 is obtained after we borrow If we add 809 and 191 then we get 1000, which is what is borrowed in order to complete the subtraction. The number 809 is said to be the 10’s complement of the number 191. This shows that: –Negative numbers can be represented in the complement’s form. –Subtraction in the decimal system, can be carried out by adding to the minuend the 10’ s complement of the subtrahend. i.e. (285) 10 - (476) 10 = (285) 10 + (-476) 10 = (285) 10 + [ (523) 9’s + + 1] = (285) 10’s + (524) 10’s = (809) 10’s –Subtraction in a system with base R, can be carried out by adding to the minuend the R’ s complement of the subtrahend.

AEEE20329 Examples on subtraction using the complement’s method Perform the following subtractions using the R’s complement method: (476) 10 - (285) 10 = (?) 10 (285) 10 - (476) 10 = (?) 10 (173) 8 - (265) 8 = (?) 8 ( ) 2 - ( ) 2 = (?) 2 (423) 5 - (234) 5 = (?) 5 (61A9) 16 - (C827) 16 = (?) 16 (61A9) 18 - (C827) 18 = (?) 18

AEEE20330 Homework: Do the necessary operations to fill up the table below:

AEEE20331 Negative Number Representation: Signed Magnitude In the Signed Magnitude representation the most significant bit is used as the sign of the number. The sign bit is zero for positive numbers and one for negative numbers. SM:8 means Signed Magnitude with 8 bits (1 for the sign and 7 for the magnitude. The problem with the SM is that there are two values for zero: ( = +0, and = -0).

AEEE20332 Negative Number Representation: One’s Complement The Ones Complement representation can be derived from the Signed Magnitude representation. If the number is positive then the one’s complement is the same as the SM. If the number is negative then the one’s complement is obtained by inverting all magnitude bits of the SM. The sign bit is unchanged. The problem with the One’s Complement is that there are two values for zero: ( = +0, and = -0).

AEEE20333 Negative Number Representation: Two’s Complement If the number is positive then the two’s complement is the same as the SM. If the number is negative then the two’s complement is obtained by adding 1to the magnitude bits of the one’s complement. The sign bit is unchanged. The two’s complement is widely used in computers to represent signed integers. In most languages such as Pascal and C an integer variable is represented in a 16-bit two’s complement representation.

AEEE20334 Negative Number Representation: Excess 2 N-1 The Excess 2 N-1 of a number is obtained by adding 2 N-1 to the number and then convert it to binary. Where N is the number of bits used to represent the number. For example if 8 bits are used then 2 N-1 is 2 7 = 128 and the system is called the Excess 128 system. Examples: (+38) 10 = = 166 = ( ) ex-128 (-38) 10 = = 90 = ( ) ex-128 ( ) ex-128 = 171 = = (+43) 10 ( ) ex-128 = 85 = = (-43) 10 Note that the 2 N-1 can also be obtained by inverting the sign bit of the two’s complement of the number.

AEEE20335 Negative Number Representation: Excess (2 N-1 -1) The Excess (2 N-1 -1)of a number is obtained by adding (2 N-1 -1)to the number and then convert it to binary. Where N is the number of bits used to represent the number. For example if 8 bits are used then (2 N-1 -1) is (2 7 -1)= 127 and the system is called the Excess 127 system. Examples: (+38) 10 = = 165 = ( ) ex-127 (-38) 10 = = 89 = ( ) ex-127 ( ) ex-128 = 171 = = (+43) 10 ( ) ex-128 = 85 = = (-43) 10 Note that the (2 N-1 -1) can be obtained by inverting the sign bit of the one’s complement of the number, ONLY if the number is positive. The (2 N-1 -1) representation is used in computers to represent the exponent of floating point numbers.

AEEE20336 Negative Number Representation: 16’s Complement Examples: (+38) 10 = = 165 = ( ) ex-127 (-38) 10 = = 89 = ( ) ex-127 ( ) ex-128 = 171 = = (+43) 10 ( ) ex-128 = 85 = = (-43) 10 The (2 N-1 -1) representation is used in computers to represent the exponent of floating point numbers.

AEEE20337 Examples Fill up the table shown below:

AEEE20338 Homework Fill up the table shown below: