Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.

Slides:



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

DATA REPRESENTATION CONVERSION.
Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
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
Number Systems. 2 The total number of allowable symbols in a number system is called the radix or base of the system. Decimal Numbers: radix = 10 (symbols:
Assembly Language and Computer Architecture Using C++ and Java
Data Representation ICS 233
ECE 331 – Digital System Design
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.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Number Representation Rizwan Rehman, CCS, DU. Convert a number from decimal to binary notation and vice versa. Understand the different representations.
Binary Representation and Computer Arithmetic
Simple Data Type Representation and conversion of numbers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Data Representation – Binary Numbers
Computers Organization & Assembly Language
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Number Systems Spring Semester 2013Programming and Data Structure1.
Chapter 2 Number Systems + Codes. Overview Objective: To use positional number systems To convert decimals to binary integers To convert binary integers.
Number Systems. Why binary numbers? Digital systems process information in binary form. That is using 0s and 1s (LOW and HIGH, 0v and 5v). Digital designer.
1 Digital Design: Number Systems Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals of Logic.
Number systems: binary, decimal, hexadecimal and octal. Conversion between various number systems Number systems: binary, decimal, hexadecimal and octal.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
مدار منطقي مظفر بگ محمدي Course Structure & Grading Homework: 25% Midterm: 30% Final:50% There is 5% extra! ( =105!) Textbook:
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter 3 Number Representation. Convert a number from decimal to binary notation and vice versa. Understand the different representations of an integer.
Number systems, Operations, and Codes
Operations on Bits Arithmetic Operations Logic Operations
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
AEEE2031 Data Representation and Numbering Systems.
Number Systems & Operations
Digital Systems Digital Logic and Design Dr. Musab Bassam Zghool Text Book: Mano Morris M. “ Digital Logic And Computer Design ”
Chapter 2 Number Systems Consists of a set of symbols called digits and a set of relations such as +, -, x, /.
69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1, * *10 + 4*1 n Alternate view: Digit position.
Introduction To Number Systems Binary System M. AL-Towaileb1.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
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.
ECE 2110: Introduction to Digital Systems
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.
Digital logic COMP214  Lecture 2 Dr. Sarah M.Eljack Chapter 1 1.
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
1. Binary, Decimal, Hexadecimal and Octal. 2. Conversion between various number systems. Number Systems:
Data Representation COE 308 Computer Architecture
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Data Representation COE 301 Computer Organization
King Fahd University of Petroleum and Minerals
Data Representation in Computer Systems
Numbering System TODAY AND TOMORROW 11th Edition
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Number Representation
Data Representation ICS 233
Data Representation COE 308 Computer Architecture
Presentation transcript:

Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement Two’s complement Excess-M representation 1

Positional Number Systems

Representing Fractions A number N r in radix r can also have a fraction part: N r = d n-1 d n-2 … d 1 d 0. d -1 d -2 … d -m  1 d -m The number N r represents the value: N r =d n-1 × r n-1 + … + d 1 × r + d 0 +(Integer Part) d -1 × r -1 + d -2 × r -2 … + d -m × r –m (Fraction Part) Integer PartFraction Part 0 ≤ d i < r Radix Point MSD LSD

Popular Number Systems Decimal Number System: Radix = 10 –Ten digit values: 0, 1, 2, …, 9 Binary Number System: Radix = 2 –Only two digit values: 0 and 1 –Numbers are represented as 0s and 1s Octal Number System: Radix = 8 –Eight digit values: 0, 1, 2, …, 7 Hexadecimal Number Systems: Radix = 16 –Sixteen digit values: 0, 1, 2, …, 9, A, B, …, F –A = 10, B = 11, …, F = 15 Octal and Hexadecimal numbers can be converted easily to Binary and vice versa

Binary/Octal/Hex-to-Decimal Conversion Binary to Decimal: N 2 =(d n-1  2 n-1 ) (d 1  2 1 ) + d 0 Octal to Decimal: N 8 = (d n-1  8 n-1 ) (d 1  8) + d 0 Hex to Decimal: N 16 = (d n-1  16 n-1 ) (d 1  16) + d 0 Examples: ( ) 2 = = 157 (7204) 8 = (7  8 3 ) + (2  8 2 ) + (0  8) + 4 = 3716 (3BA4) 16 = (3  16 3 ) + (11  16 2 ) + (10  16) + 4 = 15268

Summary of Number Systems Properties

Decimal to Binary Conversion N = (d n-1  2 n-1 ) (d 1  2 1 ) + (d 0  2 0 ) Dividing N by 2 we first obtain –Quotient 1 = (d n-1  2 n-2 ) + … + (d 2  2) + d 1 –Remainder 1 = d 0 –Therefore, first remainder is least significant bit of binary number Dividing first quotient by 2 we first obtain –Quotient 2 = (d n-1  2 n-3 ) + … + (d 3  2) + d 2 –Remainder 2 = d 1 Repeat dividing quotient by 2 –Stop when new quotient is equal to zero –Remainders are the bits from least to most significant bit

Decimal-To-Binary Integer Conversion Sum-of-Weights Methods –Determine the set of binary weights whose sum is equal to the decimal number. –Place 1s in the appropriate weight positions. 1001

Decimal-to-Hexadecimal Conversion 422 = (1A6) 16 stop when quotient is zero least significant digit most significant digit  Repeatedly divide the decimal integer by 16  Each remainder is a hex digit in the translated value  Example: convert 422 to hexadecimal  To convert decimal to octal divide by 8 instead of 16

DivisionQuotientRemainder 359/ /854 5/805 Decimal-to-Octal Conversion 359 = (547) 8 stop when quotient is zero least significant digit most significant digit  Repeatedly divide the decimal integer by 8  Each remainder is a hex digit in the translated value  Example: convert 359 to octal

Converting Decimal Fractions to Binary

Conversion Procedure to Radix r To convert decimal number N (with fraction) to radix r Convert the Integer Part –Repeatedly divide the integer part of number N by the radix r and save the remainders. The integer digits in radix r are the remainders in reverse order of their computation. If radix r > 10, then convert all remainders > 10 to digits A, B, … etc. Convert the Fractional Part –Repeatedly multiply the fraction of N by the radix r and save the integer digits that result. The fraction digits in radix r are the integer digits in order of their computation. If the radix r > 10, then convert all digits > 10 to A, B, … etc. Join the result together with the radix point

Simplified Conversions  Converting fractions between Binary, Octal, and Hexadecimal can be simplified  Starting at the radix pointing, the integer part is converted from right to left and the fractional part is converted from left to right  Group 4 bits into a hex digit or 3 bits into an octal digit  Use binary to convert between octal and hexadecimal AC Binary Hexadecimal B. 8 Octal 3. fraction: left to rightinteger: right to left

Signed Numbers Several ways to represent a signed number –Sign-Magnitude –1's complement –2's complement Divide the range of values into 2 equal parts –First part corresponds to the positive numbers (≥ 0) –Second part correspond to the negative numbers (< 0) The 2's complement representation is widely used –Has many advantages over other representations

Sign-Magnitude Representation Sign Bit bit n-2 bit 2 bit 1 bit 0... Magnitude = n – 1 bits Sign-magnitude representation of +45 using 8-bit register Sign-magnitude representation of -45 using 8-bit register

Signed Magnitude 16 Note: signed magnitude allows two different representations for zero: positive zero and negative zero.

Properties of Sign-Magnitude Two representations for zero: +0 and -0 Symmetric range of represented values: For n-bit register, range is from -(2 n-1 – 1) to +(2 n-1 – 1) For example using 8-bit register, range is -127 to +127 Hard to implement addition and subtraction –Sign and magnitude parts have to processed independently –Sign bit should be examined to determine addition or subtraction Addition is converted into subtraction when adding numbers of different signs –Need a different circuit to perform addition and subtraction Increases the cost of the logic circuit

One's Complement Representation 8-bit Binary value Unsigned value Signed value

Two's Complement Representation 8-bit Binary value Unsigned value Signed value

Forming the Two's Complement Sum of an integer and its 2's complement must be zero: = (8-bit sum)  Ignore Carry Another way to obtain the 2's complement: Start at the least significant 1 Leave all the 0s to its right unchanged Complement all the bits to its left starting value = +36 step1: reverse the bits (1's complement) step 2: add 1 to the value from step sum = 2's complement representation = -36 Binary Value = 's Complement = least significant 1

Properties of the 2’s Complement The 2’s complement of N is the negative of N The sum of N and 2’s complement of N must be zero The final carry is ignored Consider the 8-bit number N = = = 2’s complement of N = = (8-bit sum is 0) In general: Sum of N + 2’s complement of N = 2 n where 2 n is the final carry (1 followed by n 0’s) There is only one zero: 2’s complement of 0 = 0 Ignore final carry

Comparison

Exercise Show how the numbers +53 and -53 are represented in 8- bit registers using signed-magnitude, 1's complement and 2's complement representations.

24 Excess-M Representation

25 Lets compare our representations: Excess-M Representation

Quiz: Fill in the following table to indicate what each binary pattern represents using the various formats. 26 Unsigned integer 4-bit Binary Value Signed Magnitude 1’s Complement2’s ComplementExcess

Exercise - Solution Fill in the following table to indicate what each binary pattern represents using the various formats. 27