Digital Logic Lecture 2 Number Systems

Similar documents
Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

Lecture (01) Introduction Number Systems and Conversion (1)

Octal & Hexadecimal Number Systems. Digital Electronics

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

TOPICS. Other Number Systems. Other Number Systems 9/9/2017. Octal Hexadecimal Number conversion

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

MACHINE LEVEL REPRESENTATION OF DATA

Number System. Introduction. Decimal Numbers

BINARY SYSTEM. Binary system is used in digital systems because it is:

Level ISA3: Information Representation

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

Korea University of Technology and Education

Digital Fundamentals

Number representations

1.1. Unit 1. Integer Representation

MC1601 Computer Organization

CMPE223/CMSE222 Digital Logic Design. Positional representation

Information Science 1

ITEC 1011 Introduction to Information Technologies

CHW 261: Logic Design

Digital Systems and Binary Numbers

CHAPTER 2 Number Systems

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

CS & IT Conversions. Magnitude 10,000 1,

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

DIGITAL SYSTEM DESIGN

Number Systems. TA: Mamun. References: Lecture notes of Introduction to Information Technologies (ITEC 1011) by Dr Scott MacKenzie

3.1. Unit 3. Binary Representation

Chapter 1 Preliminaries

Number Systems CHAPTER Positional Number Systems

Chapter 3 DATA REPRESENTATION

Common Number Systems

TOPIC: NUMBER SYSTEMS

CMPS 10 Introduction to Computer Science Lecture Notes

Fundamentals of Programming (C)

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

umber Systems bit nibble byte word binary decimal

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

Lecture 2: Number Systems

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Chapter 2 Number Systems and Codes Dr. Xu

College of Computer and Information Sciences Department of Computer Science. CSC 220: Computer Organization. Unit1 Number Systems

Chap 1. Digital Computers and Information

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

Objectives. Connecting with Computer Science 2

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

Switching Circuits and Logic Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Ms Sandhya Rani Dash UNIT 2: NUMBER SYSTEM AND CODES. 1.1 Introduction

Outline. What Digit? => Number System. Decimal (base 10) Significant Digits. Lect 03 Number System, Gates, Boolean Algebra. CS221: Digital Design

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

COMP Overview of Tutorial #2

Number System (Different Ways To Say How Many) Fall 2016

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Digital Systems and Binary Numbers

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Digital Logic Lecture 4 Binary Codes

EEM 232 Digital System I

Chapter 2. Data Representation in Computer Systems

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Chapter 1 Emad Felemban

QUIZ: Generations of computer technology. Hardware:

T02 Tutorial Slides for Week 2

Introduction to Numbering Systems

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

D I G I T A L C I R C U I T S E E

Binary. Hexadecimal BINARY CODED DECIMAL

Chapter 2: Number Systems

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

Octal and Hexadecimal Integers

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

Number codes nibble byte word double word

DATA REPRESENTATION. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift, Jaipur Region. Based on CBSE curriculum Class 11. Neha Tyagi, KV 5 Jaipur II Shift

EE 109 Unit 2. Binary Representation Systems

What Is It? Instruction Register Address Register Data Register

Fundamentals of Programming

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation

Number Systems Base r

in this web service Cambridge University Press

Digital Systems and Binary Numbers

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Numbering systems. Dr Abu Arqoub

CS 101: Computer Programming and Utilization

6. Binary and Hexadecimal

When using computers, it should have a minimum number of easily identifiable states.

ECE 20B, Winter Purpose of Course. Introduction to Electrical Engineering, II. Administration

Beyond Base 10: Non-decimal Based Number Systems

Number Systems. Both numbers are positive

Transcription:

Digital Logic Lecture 2 Number Systems By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

Outline Introduction. Basic definitions. Number systems types. Conversion between different number systems. Examples. The Hashemite University 2

Introduction There are 4 numbering systems: Binary: 2 digits (0 and 1). Decimal: 10 digits (0 9). Octal: 8 digits (0 7). Hexadecimal: 16 digits (0 9 and A F). The binary system is what used by computers. The decimal system is what used by humans in nature (also called natural number system). Hexadecimal and Octal are a compromise representation between the binary and the decimal. The Hashemite University 3

Basic Definitions I The number of digits used within a number system is called the Radix or the Base. So: Binary Base = 2 Octal Base = 8 Decimal Base = 10 Hexadecimal Base = 16 The point in the number, i.e. fractional number, is called radix point. so, based on the radix or base you call it, e.g. in decimal you call it decimal point and in binary you call it binary point. The used digits in each numbering system are borrowed from the decimal system and completed by the alphabet characters (capital letters). In other words, you are able to use the numerals 0-9 and the alphabets A-Z based on the number of digits you need. Then you pick the wanted number of digits in order. The Hashemite University 4

Basic Definitions II For binary, you need two digits, starting from the numerals set (i.e. 0-9) you get 0 and 1 (just two digits). E.g. 10001110. For octal, you need 8 digits, following the same approach you get the digits 0-7. E.g. 756. For decimal, you need 10 digits then you get 0-9. E.g. 190. For hexadecimal you need 16 digit, starting by the numerals you get 0-9 but still you need an additional 6 digits. For this purpose you move to the alphabet letters and pick 6 letters, so you get A-F. E.g. AD4. In decimal these letters correspond to the following: A 10 B 11 C 12 D 13 E 14 F 15 The Hashemite University 5

Basic Definitions III To differentiate between numbers from the different numbering systems use one of the following: Add a subscript of the base to the number. e.g: (1000111) 2 Binary (176) 8 Octal (AD23) 16 Hexadecimal Add the following letters at the end of the number: B (Binary), Q (Octal), nothing for Decimal, H (Hexa). E.g. 10010B The universal approach to represent hexadecimal numbers is to start it with a 0 and append h to the end of the number. E.g. 0Dh. A less common approach to represent binary and hexadecimal numbers is to proceed the number with a: % for binary $ for hexadecimal e.g. %101001, $AD5 Any number proceeded by 0x is a hexadecimal number. Such representation is most commonly used in programming languages such as C++. The Hashemite University 6

Basic Definitions IV Every number in any numbering system can be represented as a weighted sum or a power series of the system radix. The coefficient of each term in the series is the digit value where the power of the base of that term depends on the location of the digit within the number with respect to the radix point (left or right). E.g.: (1890) 10 = 1x10 3 + 8x10 2 + 9x10 1 + 0x10 0 (45.678) 10 = 4x10 1 +5x10 0 +6x10-1 +7x10-2 +8x10-3 (ADF) 16 = 10x16 2 + 13x16 1 + 15x16 0 Note: the result of this power series is the decimal equivalent of the original number as we will see later. The Hashemite University 7

Basic Definitions V In computer hardware the following are used: Bit = 0 or 1 Nibble = 4 bits. Byte = 8 bits Word = 2 byte = 16 bits 2 10 = 1 Kilo = 1024 2 20 = I Mega 2 30 = 1 Giga 2 40 = 1 Tera 1 keyboard character needs 1 byte to store its value. Every thing in computers is power of 2. The architecture of the computer is determined based on its word length, e.g. 32 bit or 64 bit architecture. The Hashemite University 8

Basic Definitions VI The least significant bit (LSB) is the bit or digit that is located on the right most location within a number. The most significant bit (MSB) is the bit that is located on the leftmost position within a number. E.g.: for the number 167829, 1 is the MSB and 9 is the LSB. The Hashemite University 9

Why binary system for computers? Computers are comprised basically of switches. Switches have only tow states: either ON or OFF. As we learned, such states can be represented as two values: 1 and 0. So it is binary since there are two values and each value needs one digit or bit to represent and store it. The Hashemite University 10

Why decimal system for humans? Created with human history on earth and evolved from nature. Easy to understand. Compact: need small number of digits to represent large values. Also, humans have invented shorthand or abbreviations to simplify large decimal numbers representation to enhance readability, such as million, billion, trillion, etc. The Hashemite University 11

Conversion Between Binary and Decimal I From Binary to Decimal: Expand the binary number in a power series and sum the terms as shown previously. The same method is used when there is a radix point in the number. This method can be used to convert from any base to decimal. Examples: the binary value 11001010 represents : = 1x2 7 + 1x2 6 + 0x2 5 + 0x2 4 + 1x2 3 + 0x2 2 + 1x2 1 + 0x2 0 = 1x128 + 1x64 + 0x32 + 0x16 + 1x8 + 0x4 + 1x2 + 0x1 = 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0 =202 The Hashemite University 12

Conversion Between Binary and Decimal II From Decimal to Binary: Here there are two cases: integer decimal numbers and fraction (floating point) decimal numbers. For integer decimal numbers, there are two methods: 1-Repeated Division By 2 For this method, divide the decimal number by 2, If the remainder is 0, on the right side write down a 0. If the remainder is 1, write down a 1. Repeat the division with the result (new quotient). This process is repeated till the quotient becomes 0. When performing the division, the remainders which will represent the binary equivalent of the decimal number are written beginning at the least significant digit (right) and each new digit is written to more significant digit (the left) of the previous digit. The Hashemite University 13

Integer Decimal to Binary First Method -- Example Example: 57 / 2 = 28, remainder = 1 (binary number will end with 1) 28 / 2 = 14, remainder = 0 14 / 2 = 7, remainder = 0 7 / 2 = 3, remainder = 1 3 / 2 = 1, remainder = 1 1 / 2 = 0, remainder = 1 (binary number will start with 1) Therefore, collecting the remainders, 57 10 = 111001 2 The Hashemite University 14

Integer Decimal to Binary Second Method 2- Sum on the fly List the powers of 2 starting from 0 power where you stop at the maximum power less than the number you want to convert. See which of these powers must be included in the sum that will have the result of the decimal number that you want to convert. These powers will have 1 in its position and the powers that are not used will have 0. This method is suitable for small to mid size numbers. The Hashemite University 15

Integer Decimal to Binary Second Method -- Example Example: convert 57 10 to binary 2 5 2 4 2 3 2 2 2 1 2 0 32 16 8 4 2 1 1 1 1 0 0 1 Answer = 111001 The Hashemite University 16

Fraction Decimal to Binary As for integers, for fraction decimal numbers we use the following method: Repeated Multiplication By 2 For this method, multiply the decimal number by 2, If the integer part of the result is 0, on the right side write down a 0. If the integer part of the result is 1, write down a 1. Then remove the integer part from the result and repeat the multiplication by 2 for the fraction part. This process is repeated till the fraction becomes 0 or till you reach the sufficient accuracy. When performing the multiplication, the integers which will represent the binary equivalent of the decimal fraction are written beginning from the right of the decimal point and each new digit is written to less significant digit (the right) of the previous digit. Could be unending!!!!! The Hashemite University 17

Fraction Decimal to Binary -- Example Example: convert 0.3 10 to binary. 0.3 * 2 = 0.6 integer part = 0 0.6 * 2 = 1.2 integer part = 1 0.2 * 2 = 0.4 integer part = 0 0.4 * 2 = 0.8 integer part = 0 0.8 * 2 = 1.6 integer part = 1 0.6 * 2 = 1.2 integer part = 1, etc. Answer = 0.010011... The Hashemite University 18

Notes The same methods used to convert from decimal (integer or fraction) to binary are used to convert from decimal to any other base. Just change the radix or base value that you use in the multiplication or in the division. When you face a number that have both integer and fraction parts, e.g. 107.82 or 1011.11011, convert each part alone and then combine them. The Hashemite University 19

Why to introduce the hexadecimal and the octal (I)? Middle approach between binary and decimal systems: Binary is a must by computers but it is verbose, i.e. need large number of bits to represent small quantities, e.g. 202 10 needs 8 bits in binary. Decimal is preferred by humans, easy to understand and compact (needs small number of bits to represent values). Conversion between binary and decimal (especially decimal to binary) is not trivial and expensive in terms of the needed resources. The Hashemite University 20

Why to introduce the hexadecimal and the octal (II)? To keep commonality with binary system, ease of conversion, and the compact feature we need another number system whose base is a power of 2. Base 4 is not compact, however, base 8 (octal) and base 16 (hex) have this feature where base 16 is the most common. From here the hexadecimal system have been introduced to be a middle approach between binary, where it is easy to convert between hexa and binary, as we will see, and the compactness feature as decimal. Recall that computers store data in binary. However, hexa is commonly used in computers to represent locations (addresses) in data storage, in data access, and in RAM. The Hashemite University 21

Conversion Between Binary and Octal The octal has a base = 8 which is 2 raised to power 3. In other words, each digit in the octal system can substitute for 3 bits in the binary system. Such observation is utilized in the conversion process between octal and binary. The Hashemite University 22

Binary to Octal Conversion Start from the radix point to the left and to the right and do the following: Group the binary bits found in the binary number into groups consist of 3 bits. Substitute each group with the octal digit that represents the same quantity represented by the binary group. The same process are used with the bits on the right of the radix point (i.e. fraction). The Hashemite University 23

Binary to Octal Conversion - Example Convert the following number into octal: 10010110101111.1011111 2 010 010 110 101 111. 101 111 100 2 2 2 6 5 7. 5 7 4 8 Answer = 22657.574 8 The Hashemite University 24

Octal to Binary Conversion Just repeat the inverse of the process used to convert from binary to octal. In other words, substitute each octal digit with its 3 bit binary equivalent. Example: convert 567.42 8 to binary. 5 6 7. 4 2 8 101 110 111. 100 010 2 Answer = 101110111.100010 2 The Hashemite University 25

Octal to Decimal Conversion From Octal to Decimal: Use the power series expansion method with the base = 8. Example: convert 675.51 8 to decimal. = 6x8 2 + 7x8 1 + 5x8 0 + 5x8-1 + 1x8-2 = 445.640625 10 The Hashemite University 26

Integer Decimal to Octal Conversion From Integer Decimal to Octal: Use the repeated division method used in converting from decimal to binary but the difference here is that you divide by 8 (radix value) instead of 2. The Hashemite University 27

Integer Decimal to Octal Conversion - Example Convert (44978) 10 to Octal Division Quotient Remainder 44978 / 8 5622 2 5622 / 8 702 6 702/8 87 6 87/8 10 7 10/8 1 2 1/8 0 1 Answer = 127662 8 The Hashemite University 28

Fraction Decimal to Octal Conversion Repeated Multiplication By 8 For this method, multiply the decimal number by 8. Write down the integer part of the result. Then remove the integer part from the result and repeat the multiplication by 8 for the fraction part. This process is repeated till the fraction becomes 0 or till you reach the sufficient accuracy. When performing the multiplication, the integers which will represent the octal equivalent of the decimal fraction are written beginning from the right of the decimal point and each new digit is written to less significant digit (the right) of the previous digit. Could be unending!!!!! The Hashemite University 29

Fraction Decimal to Octal Conversion - Example Example: convert 0.356 10 to octal. 0.356 * 8 = 2.848 integer part = 2 0.848 * 8 = 6.784 integer part = 6 0.784 * 8 = 6.272 integer part = 6 0.272 * 8 = 2.176 integer part = 2 0.176 * 8 = 1.408 integer part = 1 0.408 * 8 = 3.264 integer part = 3, etc. Answer = 0.266213... 8 The Hashemite University 30

Conversion Between Binary and Hexadecimal The Hexa has a base = 16 which 2 raised to power 4. In other words, each digit in the hexa system can substitute for 4 bits in the binary system. Similar to octal, such observation is utilized in the conversion process between hexa and binary. The Hashemite University 31

Binary to Hexa Conversion Start from the radix point to the left and to the right and do the following: Group the binary bits found in the binary number into groups consist of 4 bits. Substitute each group with the Hexa digit that represents the same quantity represented by the binary group. The same process are used with the bits on the right of the radix point (i.e. fraction). The Hashemite University 32

Binary to Hexa Conversion - Example Convert the following number into Hexa: 10010110101111.1011111 2 0010 0101 1010 1111. 1011 1110 2 2 5 A F. B E 16 Answer = 25AF.BE 16 The Hashemite University 33

Hexa to Binary Conversion Just repeat the inverse of the process used to convert from binary to hexa. In other words, substitute each hexa digit with its 4 bit binary equivalent. Example: convert 56D.42 16 to binary. 5 6 D. 4 2 16 0101 0110 1101. 0100 0010 2 Answer = 010101101101.01000010 2 The Hashemite University 34

Hexa to Decimal Conversion From Hexa to Decimal: Use the power series expansion method with the base = 16. Example: convert 67B.51 16 to decimal. = 6x16 2 + 7x16 1 + 11x16 0 + 5x16-1 + 1x16-2 = 1659.316406 10 The Hashemite University 35

Integer Decimal to Hexa Conversion From Integer Decimal to Hexa: Use the repeated division method used in converting from decimal to binary but the difference here is that you divide by 16 (radix value) instead of 2. The Hashemite University 36

Integer Decimal to Octal Conversion - Example Example: Convert 35243 10 to hexa 35243 / 16 = 2202, remainder = 11 B (hex number will end with B) 2202 / 16 = 137, remainder = 10 A 137 / 16 = 8, remainder = 9 8 / 16 = 0, remainder = 8 (hex number will start with 8) Therefore, collecting the remainders, 35243 10 = 89AB 16 The Hashemite University 37

Fraction Decimal to Octal Conversion Repeated Multiplication By 16 For this method, multiply the decimal number by 16. Write down the integer part of the result. Then remove the integer part from the result and repeat the multiplication by 8 for the fraction part. This process is repeated till the fraction becomes 0 or till you reach the sufficient accuracy. When performing the multiplication, the integers which will represent the hexa equivalent of the decimal fraction are written beginning from the right of the decimal point and each new digit is written to less significant digit (the right) of the previous digit. Could be unending!!!!! The Hashemite University 38

Fraction Decimal to Octal Conversion - Example Example: convert 0.356 10 to hexa. 0.356 * 16 = 5.696 integer part = 5 0.696 * 16 = 11.136 integer part = B 0.136 * 16 = 2.176 integer part = 2 0.176 * 16 = 2.816 integer part = 2 0.816 * 16 = 13.056 integer part = D 0.056 * 16 = 0.896 integer part = 0, etc. Answer = 0.5B22D0... 16 The Hashemite University 39

Conversion Between Octal and Hexadecimal From octal to hexadecimal: First convert from octal to binary then convert the result from binary to hexadecimal. From hexadecimal to octal: First convert from hexa to binary then convert the result from binary to octal. The Hashemite University 40

Additional Notes This lecture covers the following material from the textbook: Chapter 1: Sections 1.2 1.4 The Hashemite University 41