Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.

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 Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Number System and Codes
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Mantıksal Tasarım – BBM231 M. Önder Efe
1.6 Signed Binary Numbers.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Digital Systems and Binary Numbers
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Programmable Logic Controllers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Lecture 5.
Computer Arithmetic Nizamettin AYDIN
Logic and Digital System Design - CS 303
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
IT253: Computer Organization
Binary Arithmetic & Data representation
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
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.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
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 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.
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.
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)
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.
Chapter 1: Digital Computers and Information Illustration at beginning of each Chapter Base 10 Binary Base 2 Octal Base 8 Hex bas
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
1 Lecture 3 ENGRE 254 1/14/09. 2 Lecture 1 review Digital signals assume two values represented by “0” and “1”. Typically a “0” represents a voltage near.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
AEEE2031 Data Representation and Numbering Systems.
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
MECH1500 Chapter 3.
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
Chapter 1: Binary Systems
IT1004: Data Representation and Organization Negative number representation.
NUMBER SYSTEMS AND CODES. CS Digital LogicNumber Systems and Codes2 Outline Number systems –Number notations –Arithmetic –Base conversions –Signed.
Integers’ Representation. Binary Addition. Two's Complement. Unsigned number representation Binary Addition, Subtraction. Overflow of unsigned numbers.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
Integer Operations Computer Organization and Assembly Language: Module 5.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
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.
Lecture 4: Digital Systems & Binary Numbers (4)
COMPUTER ORGANIZATION 4 TH LECTURE. ASCII Code  ASCII ( American Standard Code for Information Interchange).  Input and output devices that communicate.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 3 Data Representation
CS1010 Programming Methodology
Data Representation Data Types Complements Fixed Point Representation
Representing Information
Digital Logic & Design Lecture 02.
Data Representation – Chapter 3
Presentation transcript:

Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4

Homework Assignment Questions/Requests/Comments/Concerns?

Number Range What is meant by “range”? How do you compute the range of a given set of digits?

More Representations Integer values are represented by a power series regardless of radix (base) = 1 x x = 1 x x x x 2 0 What about fractions?

Fraction Representations Same principle applies = 1 x x x x “decimal point” = 1 x x x x 2 -2 “binary point”

Fraction Representations To convert a decimal fraction to binary –Multiple decimal fractional part by 2 –Output the integer part –Repeat until you’ve reached the desired accuracy = x x x x

Fraction Representations More on binary floating point representations later (maybe)

Addition Decimal number addition carry

Addition Binary number addition carries It works the same way in binary as it does in decimal

Subtraction Decimal number subtraction 1 1 borrow

Subtraction Binary number subtraction 01 borrow It works the same way in binary as it does in decimal

Subtraction Questions What about when a subtraction results in a negative value? How do you represent a negative value in binary? How do you represent a negative value in decimal?

Negative Numbers Decimal - 27 Place a “-” in front of the decimal digits

Negative Numbers Binary Place a “-” in front of the binary digits This is called signed-magnitude representation In the hardware the sign is a designated bit where 0 means “+” and 1 mean “–”

Negative Numbers Signed-magnitude is convenient for humans doing symbolic manipulations It’s not convenient for computer computations Why not? –Consider subtraction (which is really addition of a negative number)

Signed-Magnitude Subtraction 21 Minuend -17 Subtrahend 4 Difference 17 Minuend -21 Subtrahend - 4 Difference

Signed-Magnitude Subtraction if (M >= S) compute M-S else compute S-M place “-” on difference To perform subtraction we must first perform a comparison! –Therein lies the inconvenience

Negative Numbers Revisited Complement representation “(r-1)’s” complement –Given N r, an n-digit number of radix r –“(r-1)’s” complement is (r n – 1) - N r

“(r-1)’s” complement Decimal n=5, r=10, N=12345 ( ) ( ) –“9’s” complement

“(r-1)’s” complement Binary n=5, r=2, N=10110 (2 5 -1) ( ) –“1’s” complement –Note that the result is just an inversion of the bits of the original number (1/0 and 0/1)

“(r-1)’s” complement So, how does this help us do subtraction? –It doesn’t really! –Furthermore the representation of 0 is ambiguous 0000“+0” 1111“-0” Try it!

Another Complement “r’s” complement –Given N r, an n-digit number of radix r –“r’s” complement is “(r-1)’s” complement + 1 (r n – 1) – N r + 1 r n – N r if (N r != 0) 0 if (N r == 0)

“r’s” complement Let’s concentrate on the 2’s complement (binary number system) –“…leaving all least significant 0’s and the first 1 unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in all other higher significant bits.” Yeah, right! –Take the “1’s” complement and add 1

“2’s” Complement n=5, r=2, N=10110 (2 5 -1) ( ) ’s complement ’s complement

2’s Complement “Subtraction” Original Problem2’s Complement Problem Carry Out Answer 2’s Complement

2’s Complement “Subtraction” Original Problem2’s Complement Problem Carry Out Answer 2’s Complement

2’s Complement “Subtraction” ’s Complement Problem Carry Out Answer 2’s Complement ’s Complement Problem Carry Out Answer 2’s Complement How do we know the sign of the result?

2’s Complement “Subtraction” Recall that we’re doing “fixed bit-length” math When the numbers are “signed” then the most significant bit (MSB) represents the sign –MSB=1 defined as negative –MSB=0 defined as positive

Sign of the Result? ’s Complement Problem Carry Out Answer 2’s Complement ’s Complement Problem Carry Out Answer 2’s Complement Sign Bit

Sign of the Result? The result is in 2’s complement form –If the sign bit is 1, take the 2’s complement of the result to read off the magnitude in “normal” binary notation –If the sign bit is 0, the result is in “normal” binary notation

Overflow What if the result is too big? –Remember, this is fixed bit-length math –When you add to n-bit numbers the result may be up to n+1 bits long

Overflow When a signed positive number is added to a signed (2’s complement) negative number an overflow cannot occur –The positive number magnitude will only get smaller When two signed negative numbers or two positive numbers are added an overflow may occur –Magnitude is going to get bigger When two signed positive numbers are added, the sign bit is treated as part of the magnitude of the number and the end carry (overflow) is not treated as “overflow”

Overflow So, when is that “extra bit” an overflow and when is it part of the result? –Check the sign bit and the overflow bit –If the two are not equal then an overflow has occurred –If the two are equal then there is no overflow

Overflow In an overflow condition –If the numbers are both positive, then the sign bit becomes part of the magnitude of the result –If the numbers are both negative, then the overflow bit is treated as the sign As we’ll see next time (logic gates) there is a very simple way to detect overflow Questions?

“2’s” Complement Is this cheating on the representation of 0 since we handled it with an conditional statement? No! Try it based on the formula only! Don’t really need to specify it as two cases I only did it because the book did

“2’s” Complement So, how does this help us do subtraction? Addition of a 2’s complement subtrahend. –Take 2’s complement of the subtrahend (negate the subtrahend) –Add minuend to subtrahend –Difference is in 2’s complement notation Note we’re using a fixed, pre-specified number of bits If the result overflows, just ignore it for now

Other Binary Formats Binary Coded Decimal (BCD) –Convert each decimal digit to its binary representation and store –Requires 4 bits per digit – why? –Forget about BCD arithmetic Even parity/Odd parity –For a binary number, count the number of 1’s –If the number is odd, attach an extra “1” for even parity or a “0” for odd parity –If the number is even, attach an extra “0” for even parity or a “1” for odd parity –What good is this? Gray code –Count through a sequence of binary numbers in such a way that only 1 bit at a time changes –What good is this? American Standard Code for Information Interchange (ASCII) –Standard set of binary patterns assigned to 256 characters –How many bits comprise the ASCII code? Unicode –Up-to-date replacement for ASCII –Various schemes utilizing various bit lengths

Homework Textbook pages 89 – 91 –3-9, 3-10, 3-13, 3-15, 3-16, 3-17, 3-23 – Due beginning of next lecture Begin reading Chapter 1