1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
Binary Arithmetic Binary addition Binary subtraction
Number Systems & Operations
CHAPTER 2 Number Systems, Operations, and Codes
Chapter 1 Binary Systems 1-1. Digital Systems
King Fahd University of Petroleum and Minerals
Digital Fundamentals Floyd Chapter 2 Tenth Edition
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Number Systems Standard positional representation of numbers:
Assembly Language and Computer Architecture Using C++ and Java
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
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 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.
© 2010 Kettering University, All rights reserved..
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
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.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numbering systems.
Numeral Systems Subjects: Numeral System Positional systems Decimal
BINARY ARITHMETIC Binary arithmetic is essential in all digital computers and in many other types of digital systems.
Chapter 6 Digital Arithmetic: Operations and Circuits ECE 221 Intro
#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.
NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.
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.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
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.
Number systems, Operations, and Codes
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
Operations on Bits Arithmetic Operations Logic Operations
Microcomputers I - Electrical and Computer Engineering Dept. at Kettering.
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
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.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Introduction * Binary numbers are represented with a separate sign bit along with the magnitude. * For example, in an 8-bit binary number, the MSB is.
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
Chapter 1 Number Systems Digital Electronics. Topics discussed in last lecture Digital systems Advantages of using digital signals over analog. Disadvantages.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Introduction to Digital Electronics Lecture 2: Number Systems.
CSC 331: DIGITAL LOGIC DESIGN COURSE LECTURER: E. Y. BAAGYERE. CONTACT: LECTURE TIME: 15:40 – 17:45 hrs. VENUE: SP-LAB.
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.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
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.
Chapter 6. Digital Arithmetic: Operations and Circuits
Lecture 4: Digital Systems & Binary Numbers (4)
Computer Representation of Information
Unit 1 Introduction Number Systems and Conversion.
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
CPS120: Introduction to Computer Science
ECE 331 – Digital System Design
Chapter 1 (Part c) Digital Systems and Binary Numbers
Presentation transcript:

1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic

2  Counting in binary  Binary ↔ decimal  Hexadecimal, octal and BCD  Binary arithmetic  Signed numbers

3 Decimal numbers  Position of each digit in a weighted number system is assigned a weight based on the base or radix of the system  Radix of decimal numbers is ten, because only ten symbols (0,1,2,…,9) are used to represent any number … −1 10 −2 … (1×10 2 ) + (7×10 1 ) + (3×10 0 ) + (6×10 -1 )+(2×10 -2 ) base = 10 weights

4 Base-N numbers  Decimal numbers are just a special case of more general base-N numbers  digits take values from 0,1,…,N−1  weights have values: … N 3 N 2 N 1 N 0. N -1 N -2 …  In this course, we are interested in: N=2binary (Base-2)0,1 N=8octal (Base-8)0,1,…,7 N=10decimal0,1,…,9 N=16hexadecimal (“hex”)???

5 Counting Decimal 0,1,2,3,4,5,6,7,8,9, 10,11,12,13,…,98,99, 100,101,… Binary Only have two digits, called 0 and 1. Now the counting sequence becomes:

6 Counting in binary In-class exercise: Fill in the next eight rows

7 Counting in binary Decimal Number Binary Number N bits We meet the binary counting sequence many times in this course You’ll need to remember how to count in binary Decimal number equal to binary 111…1? 2 N - 1 Decimal number equal to binary 111…1?

8 Number systems and arithmetic  Counting in binary  Binary ↔ decimal  Hexadecimal, octal and BCD  Binary arithmetic  Signed numbers

9 1.Write the decimal weight of each column 2.Place 1 ’ s in the columns that sum to the decimal number Decimal → binary Example: Convert decimal 49 to binary Decimal 49 = binary Write: =

10 … ½ ¼ … In binary, weights are powers of 2 Binary → decimal … −1 2 −2 … ¼ = Example: Convert binary to decimal

11 Convert to decimal Convert and to binary Convert and to binary

12 Number systems and arithmetic  Counting in binary  Binary ↔ decimal  Hexadecimal, octal and BCD  Binary arithmetic  Signed numbers

13 Octal  Base-8 weighted number system  8 digits: 0,…,7  Digits 8 and 9 not allowed in octal!  Weights are powers of Example: Express in decimal 3× ×64 + 0×8 + 2×1 = DecimalOctalBinary

14 Hexadecimal ABCDEF ABCDEF DecimalHexadecimalBinary  Base-16 weighted number system  16 digits: 0,…,9 plus characters A,B,C,D,E,F  Weights are powers of 16 → compact way of writing very large numbers 1× × ×16 +15×1 = Example: Express 1A2F 16 in decimal A 2 F Hexadecimal is much more commonly used than octal

15 Convert to octal Convert to hexadecimal

16 Binary → hexadecimal Convert a binary number to hexadecimal by:  breaking binary number into 4-bit groups, starting at right- most bit  Replacing each group with equivalent hexadecimal digit Example: Express in hexadecimal F1693F = 3F Break into 4-bit groups … adding leading zeros if necessary Replace each group with hexadecimal digit

17 Binary → octal Same way as converting binary to hexadecimal except break binary number into 3-bit groups Example: Express in octal-base

DecimalBinaryBCD Binary-coded decimal (BCD) In BCD, each decimal digit is expressed with it’s 4-bit binary code  1010,1011,1100,1101,1110, 1111 are invalid BCD codes (why?)  BCD not as efficient as straight binary, but used widely for applications involving limited processing, eg. keypad inputs & clock displays Example: Express in BCD

19 Number systems and arithmetic  Counting in binary  Binary ↔ decimal  Hexadecimal, octal and BCD  Binary arithmetic  Signed numbers

20 Adding two bits Four possible cases: = 0sum=0, carry= = = 1sum=1, carry= = = 1sum=1, carry= = = 10sum=0, carry= = 2 augend addend + carry sum Decimal

21 Binary addition Example: Add the binary numbers 011 and 001 and show the equivalent decimal addition

22 Binary addition with carry in = 01sum=1, carry= = = 10sum=0, carry= = = 11sum=1, carry= = 3 Decimal When a carry is generated in one column:  need to add third bit (1) in the next column  means sum of one bit from each number, plus the carry bit

23 Example: Add the binary numbers and Show the equivalent decimal addition Binary addition

24 Number systems and arithmetic  Counting in binary  Binary ↔ decimal  Hexadecimal, octal and BCD  Binary arithmetic  Signed numbers

25 Signed numbers So far we have considered only addition of positive numbers. What about negative numbers? Signed numbers have both sign and magnitude information  Three ways of representing signed binary numbers: 1.Sign-magnitude form 2.1’s complement form 3.2’s complement form  All three methods use the sign bit (left-most bit) to tell whether the number is positive or negative:  Sign bit = 0 : positive number  Sign bit = 1 : negative number 2’s complement method is by far the most widely used method in applications

26 Signed numbers in sign-magnitude form To represent a signed binary number in sign- magnitude form:  left-most bit is the sign bit  remaining bits represent the magnitude Example: Express the decimal number −39 as an 8-bit number in sign-magnitude form Write 8-bit number for +39: (39= ) Change sign bit to a 1 to represent −39:

27 1’s complement of a binary number: change all 1s to 0s, and all 0s to 1s 1’s complement Example: Find the 1’s complement of ↓↓↓↓↓↓↓↓

28 2’s complement To get the 2’s complement of a binary number: add 1 to the 1’s complement Example: Find the 2’s complement of ’s complement 1 +add ’s complement

29 2’s complement — shortcut method 1.Start at the right-most bit and write the bits as they are, till the first 1 2.Take the 1’s complement of the remaining bits Example: Find the 2’s complement of using the shortcut method binary number ’s complement 1’s complement of original bits These bits stay the same

30 2’s complement Find the 2’s complement of using both methods described above

31 Signed numbers in 1’s complement form To represent a signed binary number in 1’s complement form:  Positive numbers:  represented as “normal” binary numbers, i.e. same as positive sign-magnitude  Negative numbers:  represented as 1’s complement of corresponding positive number Example: Represent −25 10 in 8-bit 1’s complement form = (since 25 = ) 1’s complement of is

32 Signed numbers in 2’s complement form To represent a signed binary number in 2’s complement form:  Positive numbers:  represented as “normal” binary numbers, i.e. same as positive sign-magnitude  Negative numbers:  represented as 2’s complement of corresponding positive number Example: Represent −25 10 in 8-bit 2’s complement form = ’s complement of is

33 Express as a binary number in 8-bit 2’s complement form Express −41 10 as a binary number in 8-bit 2’s complement form

34 To add two signed numbers in 2’s complement form:  Perform the addition  Discard any final carry out of MSB (=sign bit)  Result is in signed 2’s complement form  Result will be correct provided range is not exceeded Three examples: = = = = = = = = = -9 1 Discard carry out of sign bit Arithmetic with signed binary numbers: addition

35 Overflow occurs when result of addition is out of range  number of bits required to represent sum exceeds number of bits in the two numbers added  occurs if (+A) + (+B) = −Cor(−A) + (−B) = +C = = = − = − = +2 Examples: Answers are both incorrect as sign bit of result disagrees with sign of augend and addend Discard carry Overflow condition

36 Arithmetic with signed binary numbers: subtraction To subtract two signed numbers in 2’s complement form:  Take 2’s complement of subtrahend, then add the minuend  A − B = A + (−B)  Digital computers can use the same circuitry to add and subtract → saving in hardware  Remember: 2’s complement of subtrahend B is the negation of B  Discard any final carry out of MSB. The result is in signed form.

= +151 Discard carry Take 2’s complement of subtrahend and add: = = -15 Examples: same numbers on slide 14, but subtract rather than add:   = = = = +71 Discard carry = = +8 (+30) –(+15) (+14) –(-17) (-1) –(-8) Arithmetic with signed binary numbers: subtraction