CS 151 Digital Systems Design Lecture 3 More Number Systems.

Slides:



Advertisements
Similar presentations
ICS312 Set 2 Representation of Numbers and Characters.
Advertisements

Binary Systems1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
COE 202: Digital Logic Design Signed Numbers
Number Systems Discussion D4.1 Appendix C. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
Representations Example: Numbers –145 –CVL – –91 –
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
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.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
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.
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.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation and Computer Arithmetic
Dr. Bernard Chen Ph.D. University of Central Arkansas
Computer Systems 1 Fundamentals of Computing Negative Binary.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numbering systems.
Data Representation – Binary Numbers
#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
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,
Lecture Overview Introduction Positional Numbering System
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
ICS312 Set 1 Representation of Numbers and Characters.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
ECE 331 – Digital System Design
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
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.
Topic 1 – Number Systems. What is a Number System? A number system consists of an ordered set of symbols (digits) with relations defined for addition,
Operations on Bits Arithmetic Operations Logic Operations
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
1 2.1 Introduction A bit is the most basic unit of information in a computer. –It is a state of “on” or “off” in a digital circuit. –Sometimes these states.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
NUMBER SYSTEMS.
IT1004: Data Representation and Organization Negative number representation.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic Herbert G. Mayer, PSU Status 1/14/2016 Copied with Permission from prof. Mark PSU ECE.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
Computer Organization 1 Data Representation Negative Integers.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
Cosc 2150: Computer Organization
Design of Digital Circuits Reading: Binary Numbers
Number Systems Give qualifications of instructors:
Chapter 3 Data Representation
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Data Representation in Computer Systems
Unit 18: Computational Thinking
Presentation transcript:

CS 151 Digital Systems Design Lecture 3 More Number Systems

Overview °Hexadecimal numbers Related to binary and octal numbers °Conversion between hexadecimal, octal and binary °Value ranges of numbers °Representing positive and negative numbers °Creating the complement of a number Make a positive number negative (and vice versa) °Why binary?

Understanding Binary Numbers °Binary numbers are made of binary digits (bits): 0 and 1 °How many items does an binary number represent? (1011) 2 = 1x x x x2 0 = (11) 10 °What about fractions? (110.10) 2 = 1x x x x x2 -2 °Groups of eight bits are called a byte ( ) 2 °Groups of four bits are called a nibble. (1101) 2

Understanding Hexadecimal Numbers °Hexadecimal numbers are made of 16 digits: (0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F) °How many items does an hex number represent? (3A9F) 16 = 3x x x x16 0 = °What about fractions? (2D3.5) 16 = 2x x x x16 -1 = °Note that each hexadecimal digit can be represented with four bits. (1110) 2 = (E) 16 °Groups of four bits are called a nibble. (1110) 2

Putting It All Together °Binary, octal, and hexadecimal similar °Easy to build circuits to operate on these representations °Possible to convert between the three formats

Converting Between Base 16 and Base 2 °Conversion is easy!  Determine 4-bit value for each hex digit °Note that there are 2 4 = 16 different values of four bits °Easier to read and write in hexadecimal. °Representations are equivalent! 3A9F 16 = A9F

Converting Between Base 16 and Base 8 1.Convert from Base 16 to Base 2 2.Regroup bits into groups of three starting from right 3.Ignore leading zeros 4.Each group of three bits forms an octal digit = A9F 16 = A9F

How To Represent Signed Numbers Plus and minus sign used for decimal numbers: 25 (or +25), -16, etc..For computers, desirable to represent everything as bits. Three types of signed binary number representations: signed magnitude, 1’s complement, 2’s complement. In each case: left-most bit indicates sign: positive (0) or negative (1). Consider signed magnitude: = Sign bitMagnitude = Sign bitMagnitude

One’s Complement Representation The one’s complement of a binary number involves inverting all bits. 1’s comp of is ’s comp of is For an n bit number N the 1’s complement is (2 n -1) – N. Called diminished radix complement by Mano since 1’s complement for base (radix 2). To find negative of 1’s complement number take the 1’s complement = Sign bitMagnitude = Sign bitMagnitude

Two’s Complement Representation The two’s complement of a binary number involves inverting all bits and adding 1. 2’s comp of is ’s comp of is For an n bit number N the 2’s complement is (2 n -1) – N + 1. Called radix complement by Mano since 2’s complement for base (radix 2). To find negative of 2’s complement number take the 2’s complement = Sign bitMagnitude = Sign bitMagnitude

Two’s Complement Shortcuts °Algorithm 1 – Simply complement each bit and then add 1 to the result. Finding the 2’s complement of ( ) 2 and of its 2’s complement… N = [N] = °Algorithm 2 – Starting with the least significant bit, copy all of the bits up to and including the first 1 bit and then complementing the remaining bits. N = [N] =

Finite Number Representation °Machines that use 2’s complement arithmetic can represent integers in the range -2 n-1 <= N <= 2 n-1 -1 where n is the number of bits available for representing N. Note that 2 n-1 -1 = ( ) 2 and –2 n-1 = ( ) 2 oFor 2’s complement more negative numbers than positive. oFor 1’s complement two representations for zero. oFor an n bit number in base (radix) z there are z n different unsigned values. (0, 1, …z n-1 )

1’s Complement Addition °Using 1’s complement numbers, adding numbers is easy. °For example, suppose we wish to add +(1100) 2 and +(0001) 2. °Let’s compute (12) 10 + (1) 10. (12) 10 = +(1100) 2 = in 1’s comp. (1) 10 = +(0001) 2 = in 1’s comp Add carry Final Result Step 1: Add binary numbers Step 2: Add carry to low-order bit Add

1’s Complement Subtraction °Using 1’s complement numbers, subtracting numbers is also easy. °For example, suppose we wish to subtract +(0001) 2 from +(1100) 2. °Let’s compute (12) 10 - (1) 10. (12) 10 = +(1100) 2 = in 1’s comp. (-1) 10 = -(0001) 2 = in 1’s comp Add carry Final Result Step 1: Take 1’s complement of 2 nd operand Step 2: Add binary numbers Step 3: Add carry to low order bit 1’s comp Add

2’s Complement Addition °Using 2’s complement numbers, adding numbers is easy. °For example, suppose we wish to add +(1100) 2 and +(0001) 2. °Let’s compute (12) 10 + (1) 10. (12) 10 = +(1100) 2 = in 2’s comp. (1) 10 = +(0001) 2 = in 2’s comp Final Result Step 1: Add binary numbers Step 2: Ignore carry bit Add Ignore

2’s Complement Subtraction °Using 2’s complement numbers, follow steps for subtraction °For example, suppose we wish to subtract +(0001) 2 from +(1100) 2. °Let’s compute (12) 10 - (1) 10. (12) 10 = +(1100) 2 = in 2’s comp. (-1) 10 = -(0001) 2 = in 2’s comp Final Result Step 1: Take 2’s complement of 2 nd operand Step 2: Add binary numbers Step 3: Ignore carry bit 2’s comp Add Ignore Carry

2’s Complement Subtraction: Example #2 °Let’s compute (13) 10 – (5) 10. (13) 10 = +(1101) 2 = (01101) 2 (-5) 10 = -(0101) 2 = (11011) 2 °Adding these two 5-bit codes… °Discarding the carry bit, the sign bit is seen to be zero, indicating a correct result. Indeed, (01000) 2 = +(1000) 2 = +(8) carry

2’s Complement Subtraction: Example #3 °Let’s compute (5) 10 – (12) 10. (-12) 10 = -(1100) 2 = (10100) 2 (5) 10 = +(0101) 2 = (00101) 2 °Adding these two 5-bit codes… °Here, there is no carry bit and the sign bit is 1. This indicates a negative result, which is what we expect. (11001) 2 = -(7)

Summary °Binary numbers can also be represented in octal and hexadecimal °Easy to convert between binary, octal, and hexadecimal °Signed numbers represented in signed magnitude, 1’s complement, and 2’s complement °2’s complement most important (only 1 representation for zero). °Important to understand treatment of sign bit for 1’s and 2’s complement.