COE 202: Digital Logic Design Number Systems Part 2

Slides:



Advertisements
Similar presentations
ECE 331 – Digital System Design
Advertisements

COE 202: Digital Logic Design Signed Numbers
CMP 101 Fundamentals of Computer and programming in C Rohit Khokher.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
ECE 301 – Digital Electronics Course Introduction, Number Systems, Conversion between Bases, and Basic Binary Arithmetic (Lecture #1)
ECE 331 – Digital System Design
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
Number Systems and Arithmetic
COE 202: Digital Logic Design Number Systems Part 1
Mantıksal Tasarım – BBM231 M. Önder Efe
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Long multiplication Long division
© GCSE Computing Candidates should be able to:  convert positive denary whole numbers (0-255) into 8-bit binary numbers and vice versa  add two 8-bit.
Number Systems and Codes
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numbering systems.
Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school 
Computer Arithmetic Nizamettin AYDIN
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
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.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
Number systems, Operations, and Codes
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Number Base Conversions
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
ABC/ Mathematics / Chapter 1 / TP / Rev 1 © 2003 General Physics Corporation OBJECTIVES 1.Without a calculator; ADD, SUBTRACT, MULTIPLY, and DIVIDE.
Positional Number Systems Decimal, Binary, Octal and Hexadecimal Numbers Wakerly Section
AEEE2031 Data Representation and Numbering Systems.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
1 CS151 Introduction to Digital Design Chapter 1 Lecture 3.
Introduction To Number Systems Binary System M. AL-Towaileb1.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Computer Number System
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.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)
Introduction to signals The signals are broadly classified into two categories: 1. Analog Signals. 2. Digital signals.
Prepared By: Norakmar Binti Mohd Nadzari CHAPTER 2 ARITHMETIC AND LOGIC UNIT.
CPE 201 Digital Design Lecture 2: Digital Systems & Binary Numbers (2)
Introduction To Number Systems
Positional Number Systems Decimal, Binary, Octal and Hexadecimal Numbers Wakerly Section
Digital Logic & Design Adil Waheed Lecture 02.
NUMBER SYSTEMS.
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
Digital Systems and Number Systems
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CHAPTER 1 : INTRODUCTION
Number System Submitted by: Submitted to: Devashish Bhardwaj Miss.Hina
Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication.
COMPUTING FUNDAMENTALS
Number System conversions
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
King Fahd University of Petroleum and Minerals
MMNSS COLLEGE,KOTTIYAM DEPARTMENT OF PHYSICS
Overview Digital Systems and Computer Systems
Numbering System TODAY AND TOMORROW 11th Edition
Digital Logic & Design Lecture 02.
ECEG-3202 Computer Architecture and Organization
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Digital Electronics and Microprocessors
Digital Systems and Binary Numbers
Digital Logic Design (CSNB163)
ECE 301 – Digital Electronics
Binary to Decimal Conversion
Introduction To Number Systems
Dr. Clincy Professor of CS
Presentation transcript:

COE 202: Digital Logic Design Number Systems Part 2 Courtesy of Dr. Ahmad Almulhem KFUPM

Objectives Base Conversion Arithmetic operations: Decimal to other bases Binary to Octal and Hexadecimal Any base to any base Arithmetic operations: Binary number system Other number systems KFUPM

Objectives Base Conversion Arithmetic operations: Decimal to other bases Binary to Octal and Hexadecimal Any base to any base Arithmetic operations: Binary number system Other number systems KFUPM

Converting Decimal Integers to Binary Divide the decimal number by ‘2’ Repeat division until a quotient of ‘0’ is received The sequence of remainders in reverse order constitute the binary conversion Example: (41)10 = (101001)2 LSB Remainder = 1 Remainder = 0 Remainder = 0 Remainder = 1 Remainder = 0 Remainder = 1 MSB Verify: 1 x 25 + 0 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 1 x 20 = (41)10 KFUPM

Decimal to binary conversion chart KFUPM

Converting Decimal Integer to Octal Divide the decimal number by ‘8’ Repeat division until a quotient of ‘0’ is received The sequence of remainders in reverse order constitute the binary conversion Example: (153)10 = (231)8 LSB Remainder = 1 Remainder = 3 Remainder = 2 MSB Verify: 2x82 + 3 x 81 + 1 x 80 = (153)10 KFUPM

Converting Decimal Integer to Hexadecimal Divide the decimal number by ‘16’ Repeat division until a quotient of ‘0’ is received The sequence of remainders in reverse order constitute the binary conversion Example: (156)10 = (9C)16 LSB Remainder = (12)10  (C)16 Remainder = 9 MSB Verify: 9 x 161 + 12 x 160 = (156)10 KFUPM

Converting Decimal Fraction to Binary Multiply the decimal number by ‘2’ Repeat multiplication until a fraction value of ‘0.0’ is reached or until the desired level of accuracy is reached The sequence of integers before the decimal point constitute the binary number Example: (0.6875)10 = (0.1011)2 MSB 0.6875 x 2 = 1.3750 0.3750 x 2 = 0.7500 0.7500 x 2 = 1.5000 0.5000 x 2 = 1.0000 0.0000 LSB Verify: 1x2-1 + 0 x 2-2 + 1 x 2-3 + 1 x 2-4 = (0.6875)10 KFUPM

Converting Decimal Fraction to Octal Multiply the decimal number by ‘8’ Repeat multiplication until a fraction value of ‘0.0’ is reached or until the desired level of accuracy is reached The sequence of integers before the decimal point constitute the octal number Example: (0.513)10 = (0.4065…)8 MSB 0.513 x 8 = 4.104 0.104 x 8 = 0.832 0.832 x 8 = 6.656 0.656 x 8 = 5.248 . . . . LSB Verify: 4x8-1 + 0 x 8-2 + 6 x 8-3 + 5 x 8-4 = (0.513)10 KFUPM

Converting Decimal Fraction to Hexadecimal Multiply the decimal number by ‘16’ Repeat multiplication until a fraction value of ‘0.0’ is reached or until the desired level of accuracy is reached The sequence of integers before the decimal point constitute the octal number Example: (0.513)10 = (0.8353…)16 MSB 0.513 x 16 = 8.208 0.208 x 16 = 3.328 0.328 x 16 = 5.248 0.248 x 16 = 3.968 . . . . LSB Verify: 8x16-1 + 3 x 16-2 + 5 x 16-3 + 3 x 16-4 = (0.51299)10 KFUPM

Converting Integer & Fraction Q. How to convert a decimal number that has both integral and fractional parts? A. Convert each part separately, combine the two results with a point in between. Example: Consider the “decimal -> octal” examples in previous slides (153.513)10 = (231.407)8 KFUPM

Example Convert (211.6250)10 to binary? Steps: Split the number into integer and fraction Perform the conversions for the integer and fraction part separately Rejoin the results after the individual conversions KFUPM

Example (cont.) MSB Integer part fraction part LSB Remainder = 1 MSB Integer part Remainder = 1 Remainder = 0 Remainder = 0 fraction part Remainder = 1 LSB Remainder = 0 Combining the results gives us: (211.6250)10 = (11010011.101)2 Remainder = 1 Remainder = 1 KFUPM

Converting Binary to Octal Group 3 bits at a time Pad with 0s if needed Example: (11001.11)2 = (011 001.110)2 = (31.6)8 3 1 6 KFUPM

Converting Binary to Hexadecimal Group 4 bits at a time Pad with 0s if needed Example: (11001.11)2 = (0001 1001.1100)2 = (19.C)16 1 9 C KFUPM

Converting between other bases Q. How to convert between bases other than decimal; e.g from base-4 to base-6? Two steps: 1. convert source base to decimal 2. convert decimal to destination base. Exercise: (13)4 = ( ? )6 ? KFUPM

Converting between other bases Q. How to convert between bases other than decimal; e.g from base-4 to base-6? Two steps: 1. convert source base to decimal 2. convert decimal to destination base. Exercise: (13)4 = ( ? )6 ? Answer: (13)4 = (11)6 KFUPM

Converting Hexadecimal to Octal (special case) In this case, we can use binary as an intermediate step instead of decimal Example: (3A)16 = (0011-1010)2 = (000-111-010)2 = (072)8 0 added re-group by 3 KFUPM

Converting Octal to Hexadecimal (special case) In this case, we can use binary as an intermediate step instead of decimal Example: (72)8 = (111-010)2 = (0011-1010)2 = (3A)16 2 0s added re-group by 4 KFUPM

Objectives Base Conversion Arithmetic operations: Decimal to other bases Binary to Octal and Hexadecimal Any base to any base Arithmetic operations: Binary number system Other number systems KFUPM

Arithmetic Operation in base-r Arithmetic operations with numbers in base-r follow the same rules as for decimal numbers Be careful ! Only r allowed digits KFUPM

Binary Addition One bit addition: 0 0 1 1 + 0 + 1 + 0 + 1 0 0 1 1 + 0 + 1 + 0 + 1 ----- ------ ------ ------ 0 1 1 2 1 0 augend /aw-jend/ addend sum carry 2 doesn’t exist in binary! KFUPM

Binary Addition (cont.) Example: 1 1 1 1 1 1 0 0 0 0 1 1 1 1 + 0 1 1 1 1 0 1 0 1 0 -------------------------- 1 0 0 1 1 1 1 1 0 0 1 Q: How to verify? A: Convert to decimal 783 + 490 ----------- 1273 carries sum KFUPM

Binary Subtraction One bit subtraction: 0 0 1 1 - 0 - 1 - 0 - 1 0 0 1 1 - 0 - 1 - 0 - 1 ----- ------ ------ ------ 0 1 1 0 minuend /men-u-end/ subtrahend /sub-tra-hend/ difference In binary addition, there is a sum and a carry. In binary subtraction, there is a difference and a borrow Note: 0 – 1 = 1 borrow 1 borrow 1 KFUPM

Binary Subtraction (cont.) 1 0 1 0 1 - 0 1 1 -------------------------- 0 1 0 Larger binary numbers 1 1 1 1 1 1 0 0 0 0 1 1 1 1 - 0 1 1 1 1 0 1 0 1 0 -------------------------- 0 1 0 0 1 0 0 1 0 1 Verify In decimal, 783 - 490 --------- 293 borrow borrow difference difference In Decimal subtraction, the borrow is equal to 10. In Binary, the borrow is equal to 2. Therefore, a ‘1’ borrowed in binary will generate a (10)2, which equals to (2)10 in decimal KFUPM

Binary Subtraction (cont.) Subtract (11110)2 from (10011)2 00110  borrow 10011 11110 - 11110 - 10011 ----------- ----------- - 01011 01011 Note that (10011)2 is smaller than (11110)2  result is negative negative sign KFUPM

Binary Multiplication Multiply 1011 with 101: 1 0 1 1 x 1 0 1 ----------------- 0 0 0 0 ------------------------ 1 1 0 1 1 1 Rules (short cut): A ‘1’ digit in the multiplier implies a simple copy of the multiplicand A ‘0’ digit in the multiplier implies a shift left operation with all 0’s multiplicand multiplier product KFUPM

Hexadecimal addition Add (59F)16 and (E46)16 5 9 F F + 6 = (21)10 = (16 x 1) + 5 = (15)16 + E 4 6 5 + E = (19)10 = (16 x 1) + 3 = (13)16 --------- 1 3 E 5 Carry Carry 1 1 Rules: For adding individual digits of a Hexadecimal number, a mental addition of the decimal equivalent digits makes the process easier. After adding up the decimal digits, you must convert the result back to Hexadecimal, as shown in the above example. KFUPM

Octal Multiplication Multiply (762)8 with (45)8 Octal Octal Decimal Octal 7 6 2 5 x 2 = (10)10 = (8 x 1) + 2 = 12 x 4 5 5 x 6 + 1 = (31)10 = (8 x 3) + 7 = 37 -------------- 5 x 7 + 3 = (38)10 = (8 x 4) + 6 = 46 4 6 7 2 4 x 2 = (8)10 = (8 x 1) + 0 = 10 3 7 1 0 4 x 6 + 1 = (25)10 = (8 x 3) + 1 = 31 --------------- 4 x 7 + 3 = (31)10 = (8 x 3) + 7 = 37 4 3 7 7 2 Carry We use decimal representation for ease of calculation KFUPM

Conclusions To convert from decimal to base-r, divide by r for the integral part, multiply by r for the fractional part, then combine. To convert from binary to octal (hexadecimal) group bits into 3 (4). To convert between bases other than decimal, first convert source base to decimal, then convert decimal to the destination base. When performing arithmetic operations in base-r, remember allowed digits {0,..r-1}. KFUPM