Introduction to Numbering Systems

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

CHAPTER 2 (b) : AND CODES

LECTURE 1-2. Introduction and Number Systems

MACHINE LEVEL REPRESENTATION OF DATA

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

Review of Number Systems

CHW 261: Logic Design

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

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

Digital Fundamentals

Binary Systems and Codes

Number System. Introduction. Decimal Numbers

Computer Organization

CS & IT Conversions. Magnitude 10,000 1,

Number representations

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

Digital Systems and Binary Numbers

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

Number Systems CHAPTER Positional Number Systems

Final Labs and Tutors

Binary Codes. Dr. Mudathir A. Fagiri

Chapter 3 DATA REPRESENTATION

Chapter 1 Emad Felemban

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

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

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

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

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

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

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

Chapter 2. Data Representation in Computer Systems

Electronic Data and Instructions

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Chapter 2 Bits, Data Types, and Operations

Objectives. Connecting with Computer Science 2

Lecture (02) Operations on numbering systems

Digital Fundamentals

The. Binary. Number System

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

umber Systems bit nibble byte word binary decimal

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

Chapter 2 Bits, Data Types, and Operations

NUMBER SYSTEMS AND CODES

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

Octal & Hexadecimal Number Systems. Digital Electronics

EEM 232 Digital System I

Lecture 2: Number Systems

What Is It? Instruction Register Address Register Data Register

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

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

CMPS 10 Introduction to Computer Science Lecture Notes

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

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

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

Positional Number System

Level ISA3: Information Representation

World Inside a Computer is Binary

Chapter 2 Bits, Data Types, and Operations

Microcomputers. Outline. Number Systems and Digital Logic Review

COMP Overview of Tutorial #2

Memory Addressing, Binary, and Hexadecimal Review

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

Chapter 2 Data Representations

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

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

CMPE223/CMSE222 Digital Logic Design. Positional representation

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

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

Chapter 1. Digital Systems and Binary Numbers

CHAPTER 2 Data Representation in Computer 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.

Chap 1. Digital Computers and Information

CHAPTER 2 Number Systems

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

Chapter 2 Binary Values and Number Systems

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Data Representations & Arithmetic Operations

Beyond Base 10: Non-decimal Based Number Systems

DIGITAL SYSTEM DESIGN

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

Octal and Hexadecimal Integers

Numbering systems. Dr Abu Arqoub

EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Dec Hex Bin ORG ; ZERO. Introduction To Computing

in this web service Cambridge University Press

Chapter 2: Number Systems

Chapter 1 Review of Number Systems

CHAPTER 2 Data Representation in Computer Systems

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Lecture 1: Digital Systems and Number Systems

Korea University of Technology and Education

Binary. Hexadecimal BINARY CODED DECIMAL

Digital Systems and Binary Numbers

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

Binary Representations and Arithmetic

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Fundamentals of Programming (C)

Number Systems & Encoding

EE 8351 Digital Logic Circuits Ms. J.Jayaudhaya, ASP/EEE

Transcription:

NUMBER SYSTEM

Introduction to Numbering Systems We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are Binary Base 2 Octal Base 8 Hexadecimal Base 16 2

Characteristics of Numbering Systems 1) The digits are consecutive. 2) The number of digits is equal to the size of the base. 3) Zero is always the first digit. 4) The base number is never a digit. 5) When 1 is added to the largest digit, a sum of zero and a carry of one results. 6) Numeric values determined by the have implicit positional values of the digits.

Significant Digits Binary: 11101101 Most significant bit Least significant bit Hexadecimal: 1D63A7A Most significant digit Least significant digit

Data Representation? 1) Representation = Measurement 2) Most things in the Real World actually exist as a single, continuously varying quantity Mass, Volume, Speed, Pressure, Temperature 3) Easy to measure by representing it using a different thing that varies in the same way Eg. Pressure as the height of column of mercury or as voltage produced by a pressure transducer 4) These are ANALOG measurements 5

Digital Representation Convert ANALOG to DIGITAL measurement by using a scale of units DIGITAL measurements In units a set of symbolic values - digits Values larger than any symbol in the set use sequence of digits Units, Tens, Hundreds Measured in discrete or whole units Difficult to measure something that is not a multiple of units in size. Eg Fractions 6

Analog vs. Digital representation 7

Data Representation Computers use digital representation Based on a binary system (uses on/off states to represent 2 digits). Many different types of data. Examples? ALL data (no matter how complex) must be represented in memory as binary digits (bits). 8

Number systems and computers Computers store all data as binary digits, but we may need to convert this to a number system we are familiar with. Computer programs and data are often represented (outside the computer) using octal and hexadecimal number systems because they are a short hand way of representing binary numbers. 9

Number Systems - Decimal The decimal system is a base-10 system. There are 10 distinct digits (0 to 9) to represent any quantity. For an n-digit number, the value that each digit represents depends on its weight or position. The weights are based on powers of 10. 1024 = 1*10 3 + 0*10 2 + 2*10 1 + 4*10 0 = 1000 + 20 + 4 10

Binary Number System Also called the Base 2 system The binary number system is used to model the series of electrical signals computers use to represent information 0 represents the no voltage or an off state 1 represents the presence of voltage or an on state

Binary Addition 4 Possible Binary Addition Combinations: (1) 0 (2) 0 +0 +1 Carry 00 01 Sum Note that leading zeroes are frequently dropped. (3) 1 (4) 1 +0 +1 01 10

Decimal to Binary Conversion The easiest way to convert a decimal number to its binary equivalent is to use the Division Algorithm This method repeatedly divides a decimal number by 2 and records the quotient and remainder The remainder digits (a sequence of zeros and ones) form the binary equivalent in least significant to most significant digit sequence

Division Algorithm Convert 67 to its binary equivalent: 67 10 = x 2 Step 1: 67 / 2 = 33 R 1 Step 2: 33 / 2 = 16 R 1 Step 3: 16 / 2 = 8 R 0 Step 4: 8 / 2 = 4 R 0 Step 5: 4 / 2 = 2 R 0 Step 6: 2 / 2 = 1 R 0 Divide 67 by 2. Record quotient in next row Again divide by 2; record quotient in next row Repeat again Repeat again Repeat again Repeat again Step 7: 1 / 2 = 0 R 1 STOP when quotient equals 0 1 0 0 0 0 1 1 2

Binary to Decimal Conversion The easiest method for converting a binary number to its decimal equivalent is to use the Multiplication Algorithm Multiply the binary digits by increasing powers of two, starting from the right Then, to find the decimal number equivalent, sum those products

Multiplication Algorithm Convert (10101101) 2 to its decimal equivalent: Binary 1 0 1 0 1 1 0 1 Positional Values Products x x x x x x x x 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 128 + 32 + 8 + 4 + 1 173 10

Octal Number System Also known as the Base 8 System Uses digits 0-7 Readily converts to binary Groups of three (binary) digits can be used to represent each octal digit Also uses multiplication and division algorithms for conversion to and from base 10

Decimal to Octal Conversion Convert 427 10 to its octal equivalent: 427 / 8 = 53 R3 Divide by 8; R is LSD 53 / 8 = 6 R5 Divide Q by 8; R is next digit 6 / 8 = 0 R6 Repeat until Q = 0 653 8

Octal to Decimal Conversion Convert 653 8 to its decimal equivalent: Octal Digits Positional Values Products 6 5 3 x x x 8 2 8 1 8 0 384 + 40 + 3 427 10

Octal to Binary Conversion Each octal number converts to 3 binary digits To convert 653 8 to binary, just substitute code: 6 5 3 110 101 011

Hexadecimal Number System Base 16 system Uses digits 0-9 & letters A,B,C,D,E,F Groups of four bits represent each base 16 digit

Decimal to Hexadecimal Conversion Convert 830 10 to its hexadecimal equivalent: 830 / 16 = 51 R14 51 / 16 = 3 R3 3 / 16 = 0 R3 = E in Hex 33E 16

Hexadecimal to Decimal Conversion Convert 3B4F 16 to its decimal equivalent: Hex Digits 3 B 4 F Positional Values x x x 16 3 16 2 16 1 16 0 x Products 12288 +2816 + 64 +15 15,183 10

Binary to Hexadecimal Conversion The easiest method for converting binary to hexadecimal is to use a substitution code Each hex number converts to 4 binary digits

Substitution Code Convert 010101101010111001101010 2 to hex using the 4-bit substitution code : 0101 0110 1010 1110 0110 1010 5 6 A E 6 A 56AE6A 16

Substitution Code Substitution code can also be used to convert binary to octal by using 3-bit groupings: 010 101 101 010 111 001 101 010 2 5 5 2 7 1 5 2 25527152 8

Complementary Arithmetic 1 s complement Switch all 0 s to 1 s and 1 s to 0 s Binary # 10110011 1 s complement 01001100

Complementary Arithmetic 2 s complement Step 1: Find 1 s complement of the number Binary # 11000110 1 s complement 00111001 Step 2: Add 1 to the 1 s complement 00111001 + 00000001 00111010

Negative Integers One s (1 s) Complement Computers generally use a system called complementary representation to store negative integers. Two basic types - ones and twos complement, of which 2 s complement is the most widely used. The number range is split into two halves, to represent the positive and negative numbers. Negative numbers begin with 1, positive with 0. 29

Negative Integers One s (1 s) Complement To perform 1 s complement operation on a binary number, replace 1 s with 0 s and 0 s with 1 s (ie Complement it!) +6 represented by: 00000110-6 represented by: 11111001 Advantages: arithmetic is easier (cheaper/faster electronics) Fairly straightforward addition Add any carry from the Most Significant (left-most) Bit to Least Significant (right-most) Bit of the result For subtraction form 1 s complement of number to be subtracted and then add Disadvantages : still two representations for zero 00000000 and 11111111 (in 8-bit representation) 30

Negative Integers Two s (2 s) Complement To perform the 2 s complement operation on a binary number replace 1 s with 0 s and 0 s with 1 s (i.e. the one s complement of the number) add 1 +6 represented by: 00000110-6 represented by: 11111010 Advantages: Arithmetic is very straightforward End Around Carry is ignored only one representation for zero (00000000) 31

Negative Integers Two s (2 s) Complement Two s Complement To convert an integer to 2 s complement»take the binary form of the number 00000110(6 as an 8-bit representation)»flip the bits: (Find 1 s Complement) 11111001»Add 1 11111001 +1 11111010 (2 s complement of 6) Justification of representation: 6+(-6)=0? 00000110 (6) +11111010 (2 s complement of 6) 100000000 (0) 32

Negative Integers Two s (2 s) Complement Interpretation of Negative Results 00000101 ( 5) +11110100 (-12) 11111001 ( ) Result is negative Negative what? Take the 2 s comp of the result to find out since the 2 s comp of a 2 s comp is the original number Negative 7 the 2 s complement of 11111001 is 00000111 or 7 10 33

Problem: word size is fixed, but addition can produce a result that is too large to fit in the number of bits available. This is called overflow. If two numbers of the same sign are added, but the result has the opposite sign then overflow has occurred Overflow can occur whether or not there is a carry Examples: 01000000 ( +64) 10000000 (-128) 01000001 ( +65) 11000000 ( -64) 10000001 (-127) 01000000 ( +64) 34

Binary Coded Decimal Scheme whereby each decimal digit is represented by its 4-bit binary code 7 = 0111 246 = 001001000110 Many CPUs provide arithmetic instructions for operating directly on BCD. However, calculations slower and more difficult. 35

Data Representation Computers store everything as binary digits. So, how can we encode numbers, images, sound, text?? We need standard encoding systems for each type of data. Some standards evolve from proprietary products which became very popular. Other standards are created by official industry bodies where none previously existed. Some example encoding standards are? 36

Alphanumeric Data Alphanumeric data such as names and addresses are represented by assigning a unique binary code or sequence of bits to represent each character. As each character is entered from a keyboard (or other input device) it is converted into a binary code. Character code sets contain two types of characters: Printable (normal characters) Non-printable. Characters used as control codes. CTRL G (beep) CTRL Z (end of file) 37

Alphanumeric Codes There are 3 main coding methods in use: ASCII EBCDIC 38

7-bit code (128 characters) ASCII has an extended 8-bit version used on PC s and non-ibm mainframes widely used to transfer data from one computer to another 39

EBCDIC An 8-bit code (256 characters) Different collating sequence to ASCII used on mainframe IBM machine Both ASCII and EBCDIC are 8 bit codes inadequate for representing all international characters Some European characters Most non-alphabetic languages eg : Mandarin, Kanji, Arabic, etc 40