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

Similar documents
Digital Fundamentals

CHW 261: Logic Design

Chapter 2 Number Systems and Codes Dr. Xu

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

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

Lecture 2: Number Systems

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

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

Korea University of Technology and Education

Chapter 1. Digital Systems and Binary Numbers

CHAPTER 2 (b) : AND CODES

Binary Codes. Dr. Mudathir A. Fagiri

Lecture (02) Operations on numbering systems

Digital Fundamentals

MACHINE LEVEL REPRESENTATION OF DATA

Numbering systems. Dr Abu Arqoub

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

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

Digital Fundamentals

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

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

DIGITAL SYSTEM DESIGN

Data Representation and Binary Arithmetic. Lecture 2

Digital Systems and Binary Numbers

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Number Systems. Dr. Tarek A. Tutunji Philadelphia University, Jordan

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

Digital Systems and Binary Numbers

Review of Number Systems

Number representations

CS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq

Computer Organization

World Inside a Computer is Binary

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Lecture (03) Binary Codes Registers and Logic Gates

CS & IT Conversions. Magnitude 10,000 1,

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

Chapter 1 Review of Number Systems

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.

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Binary Systems and Codes

UNIT 7A Data Representation: Numbers and Text. Digital Data

Number Systems Base r

Digital Systems and Binary Numbers

Chapter 2 Number System

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Number System. Introduction. Decimal Numbers

COMP Overview of Tutorial #2

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

MC1601 Computer Organization

Positional Number System

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

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

Microcomputers. Outline. Number Systems and Digital Logic Review

Module 2: Computer Arithmetic

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

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

EE 109 Unit 6 Binary Arithmetic

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

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

Octal & Hexadecimal Number Systems. Digital Electronics

CMPE223/CMSE222 Digital Logic Design. Positional representation

Chapter 2. Data Representation in Computer Systems

Introduction to Numbering Systems

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

Number Systems CHAPTER Positional Number Systems

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

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

Final Labs and Tutors

Agenda EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 1: Introduction. Go over the syllabus 3/31/2010

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

Chapter 10 Binary Arithmetics

The Gray Code. Script

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Fundamentals of Programming (C)

ENE 334 Microprocessors

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

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Electronic Data and Instructions

Arithmetic Operations

SE311: Design of Digital Systems

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Chapter 5: Computer Arithmetic. In this chapter you will learn about:

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Number codes nibble byte word double word

Level ISA3: Information Representation

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

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

Learning Objectives. Binary over Decimal. In this chapter you will learn about:

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

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

Chapter (1) Eng. Mai Z. Alyazji

NUMBER SYSTEMS AND CODES

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

umber Systems bit nibble byte word binary decimal

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Transcription:

CHAPTER 2

CHAPTER CONTENTS 2.1 Binary System 2.2 Binary Arithmetic Operation 2.3 Signed & Unsigned Numbers 2.4 Arithmetic Operations of Signed Numbers 2.5 Hexadecimal Number System 2.6 Octal Number System 2.7 Digital Codes 2.8 Error Detection

LEARNING OUTCOMES At the end of this chapter, you must be able to Describe the foundation for a positional number system Understand the relation between the binarydecimal number system Count in the binary system Understand the hexadecimal & octal number systems shorthand for binary number system Describe what the digital codes are Explain the error detection in digital codes

BINARY SYSTEM Binary system is used in digital systems because it is: Easy to implement Accurate 2 levels of voltage is required to represent the digits A symbol/digit in binary number system is known as a bit. bit = an acronym of binary digit. Digital circuits use binary number system to represent quantities.

BINARY SYSTEM

BINARY SYSTEM Binary to decimal conversion -As binary is a positional numbering system, each bit has different weight depending on the bits position.

BINARY SYSTEM E X A M P L E S (a) 1001101 2 = (1 2 6 ) + (0 2 5 ) + (0 2 4 ) + (1 2 3 ) + (1 2 2 ) + (0 2 1 ) + (1 2 0 ) = (1 64) + (0 32) + (0 16) + (1 8) + (1 4) + (0 2) + (1 1) = 64 + 8 + 4 + 1 = 77 10 (b) 1101100 2 = (1 2 6 ) + (1 2 5 ) + (0 2 4 ) + (1 2 3 ) + (1 2 2 ) + (0 2 1 ) + (0 2 0 ) = (1 64) + (1 32) + (0 16) + (1 8) + (1 4) + (0 2) + (0 1) = 64 + 32 + 8 + 4 = 108 10 (c) 10100 2 = (1 2 4 ) + (0 2 3 ) + (1 2 2 ) + (0 2 1 ) + (0 2 0 ) = (1 16) + (0 8) + (1 4) + (0 2) + (0 1) = 16 + 4 = 20 10

BINARY SYSTEM Decimal to Binary conversion Reverse process steps: Note that all positions must be accounted for 5 2 3710 2 0 0 2 0 2 1 0 0 1 0 12 Repeated division steps: Divide the decimal number by 2 Write the remainder after each division until a quotient of zero is obtained. The first remainder is the LSB and the last is the MSB 0

BINARY SYSTEM

BINARY ARITHMETIC OPERATION Addition Subtraction Multiplication 0 + 0 = 0 0-0 = 0 0 0 = 0 0 + 1 = 1 0-1 = 1 + 1 (borrow) 0 1 = 0 1 + 0 = 1 1-0 = 1 1 0 = 0 1 + 1 = 0 + 1 (carry) 1-1 = 0 1 1 = 1

BINARY ARITHMETIC OPERATION ADD (a) 11+11 = 110 (b) 100+10= 110 (c) 110+100= 1010 (d) 111+11= 1010 SUBTRACT (a) 11-01= 10 (b) 11-10= 01 (c) 101-011= 010

BINARY ARITHMETIC OPERATION MULTIPLICATION (a) 11 x 11 = 1001 (b) 111x101= 100011 DIVISION (a) 110/11=10 (b) 110/10=11

SIGNED & UNSIGNED NUMBERS In binary system, 3 forms of signed number are popular: - Signed-magnitude - 1 s complement - 2 s complement

SIGNED MAGNITUDE The left-most bit (MSB) is used as sign indicator. 0 Positive number 1 Negative number Example: Write -65 10 in signed magnitude form using 8-bit binary

1 S COMPLEMENT For POSITIVE number, the representation is similar to the signed magnitude form. For NEGATIVE number, the representation is the 1 s complement of the positive number, i.e. invert all the bits of its equivalent positive number 0 1 and 1 0 Example: 10110010 01001101 00011010 11100101

2 S COMPLEMENT Finding 2 s complement by adding 1 to the LSB of 1 s complement number or Using alternative method: - start from LSB, write the same bit until you find the first 1 - next take the 1 s complement of the remaining bits Example: 10110010 01001101 +1 = 01001110 10111000 10111000 01001000

RANGE OF BINARY NUMBERS UNSIGNED BINARY NUMBER All the bits are used to represent the number range 0 to 2 n 1 e.g. for 8-bit binary range 0 10 to 255 10 SIGNED BINARY NUMBER As MSB is used to indicate the sign (+ve or ve) range ( 2 n-1 ) to 2 n-1 1 e.g. for 8-bit binary range -128 10 to +127 10

ARITHMETIC OPERATIONS OF SIGNED NUMBERS The operations available for signed numbers are +,, and. However, + is mostly used in digital system. This is because most ALUs are only capable of doing the +. As the 2 s complement is widely used in computers, therefore we are going to learn the ADDITION & SUBTRACTION for 2 s complement numbers

ADDITION OF SIGNED NUMBERS There are 4 cases that can occur 1.Both numbers are positive + number 2.Positive number with magnitude larger than negative number + number 3.Positive number with magnitude smaller than negative number - number 2 s C 4.Both numbers negative overflow * add the numbers and discard the final carry bit

ADDITION OF SIGNED NUMBERS Case 1: 00000111+00000100 = 00001011 Case 2: 00001111+11111010 = 100001001 Case 3: 00010000+11101000 = 11111000 Case 4: 11111011+11110111 = 111110010 ** Overflow case If the sign bit result is different than the sign bit of the numbers added, overflow is indicated Eg: 01111101+00111010 = 10110111

SUBTRACTION OF SIGNED NUMBER It is a special case of addition i.e. take the two signed numbers, take the 2 s complement of the subtrahend and add. Discard carry bit. Meaning we have to change the sign of subtrahend using 2 s complement form. Example: 00001000 00000011 11111101 00001000+11111101 = 100000101 Example: 11100111-00010011 11101101 11100111 + 1110110 = 111010100

MULTIPLICATION OF SIGNED NUMBERS Step 1 determine the sign (+/-) ** if - then must also use 2 s complement. Since we use only true form. Step 2 perform 2 s complement to multiplier Step 3 perform multiplication to magnitude bit If multiplier 1 follows multiplicand value If multiplier 0 become 0 Step 4 add each result with the sum of previous partial product. Shift left one bit. Step 5 if the sign in step 1 is negative, take 2 s complement of the product. Attach the sign bit 1

HEXADECIMAL NUMBER SYSTEM Also known as BASE 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F It is a positional numeral system. Example: Given a hexadecimal number of 4A9 For digit 4 4 x 16 2 digit A A (=10) x 16 1 digit 9 9 x 16 0

BINARY TO HEXADECIMAL CONVERSION Each hexadecimal digit = 4 bits (or 1 nibble) To convert, group the binary number in groups of 4 (starting with LSB) then write down the equivalent hexadecimal digit

BINARY TO HEX HEX TO BINARY

HEXADECIMAL TO DECIMAL CONVERSION 79 16 = (7 16 1 ) + (9 16 0 ) = (7 16) + (9 1) = 112 + 9 = 121 10 E0 16 = (14 16 1 ) + (0 16 0 ) = (14 16) + (0 1) = 224 = 224 10 AB 16 = (10 16 1 ) + (11 16 0 ) = (10 16) + (11 1) = 160 + 11 = 171 10

DECIMAL TO HEXADECIMAL CONVERSION

OCTAL NUMBER SYSTEM Also known as BASE 8 0, 1, 2, 3, 4, 5, 6, 7 It is a positional numeral system. Example: Given an octal number of 463 For digit 4 4 x 8 2 digit 6 6 x 8 1 digit 3 3 x 8 0

BINARY TO OCTAL OCTAL TO BINARY

OCTAL TO DECIMAL CONVERSION 2 1 1638 1 (8 ) 6 (8 ) 3 (8 1 64 48 3 1 115 10 0 ) 2374 8 3 2 1 0 (2 8 ) (3 8 ) (7 8 ) (4 8 ) ( 2 512) (3 64) (7 8) (4 1) 1276 10

DECIMAL TO OCTAL CONVERSION

HEXADECIMAL TO OCTAL CONVERSION

OCTAL TO HEXADECIMAL CONVERSION

DIGITAL CODES Encode a process where numbers, letters or words are represented by a special group of symbols. Code the group of symbols Several types of Digital Code Binary-Coded-Decimal (BCD) Code Gray Code ASCII Code

BINARY CODED DECIMAL (BCD CODE) Since the largest decimal is 9 10 (=1001 2 ), therefore 4 bits are required to code each decimal s digit. BCD is not a number system. BCD is a decimal number with each digit encoded to its binary equivalent. BCD number is not the same as a straight binary number.

BCD CODE The primary advantage of BCD is the relative ease of converting to and from decimal. Each digit always uses four bits. The BCD value can never be greater than 9 Reverse the process to convert BCD to decimal. Example: Write the BCD code for 579 10. Ans: The BCD code is 0101 0111 1001

BCD CODE DECIMAL TO BCD 3 5 0 0 1 1 0 1 0 1 1 7 0 0 0 0 1 0 1 1 1 0 0 0 0 BCD TO DECIMAL 0 0 1 1 0 1 0 1 0 0 0 1 3 5 1 1 0 0 0 0 1 1 0 8 6

GRAY CODE Gray code is a way to represent a sequence of numbers. Important feature: only 1 bit is changed at a time Purpose of using this code: to minimise the error when counting in sequence

BINARY TO GRAY CODE CONVERSION

GRAY CODE TO BINARY CONVERSION

AMERICAN STANDARD CODE FOR INFORMATION INTERCHANGE (ASCII CODE) ASCII codes represent text in computers, communication devices, etc. It is an alphanumeric code with 2 7 (i.e. 128) possible code groups. meaning a code is consists of 7-bit binary As most computers deal with 8-bit binary group, normally an 8 th bit is commonly used as a parity bit.

ASCII CODE

ERROR DETECTION There is a possibility that errors can occur during data transmission. DATA SEND DATA RECEIVED Major cause electrical noise (spurious fluctuation in voltage or current) Due to the large size of data, many digital systems employ some method to detect (and sometimes to correct) the error. e.g. Parity bit method

PARITY BIT Parity bit is an extra bit attached to a code group that is being transferred. There are 2 types of parity method: EVEN-parity method ODD-parity method Parity bit could be 1 or 0 depending on the number of 1s available in the code (and also what type of parity method is employed)

EVEN PARITY The value of the parity bit is chosen so that the total number of 1s in the code group (including the parity bit) is an even number. Example: A code 1000011 is to be sent to a printer. What is the parity bit to be attached to the code if an even parity method is employed? Solution: Number of 1s in the code = 3. Therefore, a parity bit of 1 is used. Now, total number of 1s = 4 (even) Code sent = 1100 0011

ODD PARITY The value of the parity bit is chosen so that the total number of 1s in the code group (including the parity bit) is an odd number. Example: A code 1000011 is to be sent to a printer. What is the parity bit to be attached to the code if an odd parity method is employed? Solution: Number of 1s in the code = 3 (odd) Therefore, a parity bit of 0 is used. Code sent = 1100 0011