Dale & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

EMB1006 The Binary System There is no 2 Jonathan-Lee Jones.
King Fahd University of Petroleum and Minerals
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
Signed Numbers Up till now we've been concentrating on unsigned numbers. In real life we have to represent signed numbers ( like: -12, -45, 78). The difference.
Signed Numbers.
Assembly Language and Computer Architecture Using C++ and Java
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
ECE 331 – Digital System Design
ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.
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.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Number System and Codes
Number Systems Lecture 02.
Number Systems Computer Science 210 Computer Organization.
3. Representing Integer Data
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
Binary Representation and Computer Arithmetic
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
1 Week 3: Data Representation: Negative Numbers READING: Chapter 3.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
General Fixed Radix Number Systems Nonredundant Positive radix, ß n digits in digit set Vector:
Chapter 7 Arithmetic Operations and Circuits Binary Arithmetic Addition –When the sum exceeds 1, carry a 1 over to the next-more-significant column.
Representing Integer Data Book : Chapter ( Subject has no point !! ) A99ACF.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
#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.
Binary Arithmetic & Data representation
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
ECE 331 – Digital System Design
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Positional Number Systems
Number Representation
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.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
1 Review on Number Systems Decimal, Binary, and Hexadecimal.
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
NUMBER SYSTEMS.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
Computer Organization 1 Data Representation Negative Integers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Binary Arithmetic James A. Rome Tennessee Governor's Academy August 2010.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Unit 18: Computational Thinking
CS 101 – Sept. 4 Number representation Integer Unsigned √ Signed √
Presentation transcript:

Dale & Lewis Chapter 3 Data Representation

Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video, images, graphics, etc. −How do you convert these to 0s and 1s? −How do you store the digital information efficiently?

Representing numeric data Representing Natural numbers with a finite number of digits General Property: Number of digitsMinMax n0b n -1 Example: −b=10, n=3000 to 999 −b=2, n=3000 to 111 (equivalent to 0 to 7 in decimal) −b=8, n=3000 to 777 (equivalent to 0 to 511 in decimal) −b=16, n=3000 to FFF (equivalent to 0 to 4,095 in decimal)

Representing negative numbers (integers) Basic definition −An integer is a number with no fractional part −Examples: Integers (signed natural numbers) −Previously we looked at unsigned numbers, i.e. natural numbers −Need a mechanism to represent both positive and negative numbers −Two schemes: 1) sign-magnitude, 2) complementary representaion

Sign-magnitude In binary: −Sign: left-most bit (0 = positive, 1 = negative) −Magnitude: remaining bits Example with 6-bit sign-magnitude representation +5 = = Ranges in binary UnsignedSign-magnitude # of bitsMinMaxMinMax n02 n -1-(2 n-1 -1) +(2 n-1 -1)

Complementary representation Difficulties with Sign-magnitude −Two representations for zero +0 = = −Arithmetic is awkward, especially subtraction Complementary representation −Positive numbers are represented by their corresponding natural numbers −Negative numbers are represented as very large natural numbers −Subtracting numbers reduces to performing addition operations negative numbers: negative(x) ≡ b n -x

Complementary representation negative numbers: negative(x) ≡ b n -x Example: let b = 10 and n = 2 Positive numbersNegative numbers (+0) 00 (+1) 01(-1) 99 (+2) 02(-2) 98 (+3) 03(-3) 97 … (+49) 49(-49) 51 (-50) 50

Visualization

Examples of arithmetic in Ten’s complement -35 plus +25 equals plus 25 equals 90  Ten’s complement +17 plus +25 equals plus 25 equals 42  Ten’s complement +20 plus -30 equals plus 70 equals 90  Ten’s complement -20 plus +30 equals plus 30 equals 10 (110)  Ten’s complement

Examples of arithmetic in Ten’s complement Subtraction reduces to addition because A – B = A + (-B) Easy to convert between positive number and its negative counterpart −This conversion can be made efficiently and simplify logic circuitry (we will see how)

Two’s complement representation Negative numbers: negative(x) ≡ 2 n -x Used in computers because subtraction reduces to addition  simpler circuits To form a negative number −Start with the positive version of the number −Flip the bits: 0  1 and 1  0 −Add 1 to the number produced in the previous step Same process for conversion back to positive numbers The above steps are an indirect way of carrying our the evaluation of 2 n -x, or more conveniently [(2 n -1)-x]+1

Examples of Two’s complement +5 (0101) to -5 (1011) -5 (1011) to +5 (0101) Evaluating 2 n -x is = 16-5 = Or 1011 Evaluating [(2 n -1)-x]+1 is [ ( )-5]+1 = = (this way you never borrow)

+2 = = = = = = ↑ throw away -2 = 1110 = = 0010 = = = = = = = 1111 ↑ throw away

Sample test/exam questions Q: Convert -173 to 12-bit two’s complement representation. Show all your work. A: Step 1: Convert 173 to binary by repeated division by ÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷

Sample test/exam questions Q: Convert -173 to 12-bit two’s complement representation. Show all your work. A: Step 1: Convert 173 to binary by repeated division by 2  Step 2: Expand answer in Step 1 to 12-bits  Step 3: Flip-the-bits and add one  Final answer: -173 =

Sample test/exam questions Q: Convert +173 to 12-bit two’s complement representation. Show all your work. Q: Convert the 12-bit two’s complement number to decimal.