Number Systems. Before the inception of digital computers, the only number system

Similar documents
Lecture 11: Number Systems

CPEN Digital Logic Design Binary Systems

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

CSI 333 Lecture 1 Number Systems

Base Conversion written by Cathy Saxton

NUMBER SYSTEMS. 1.1 Introduction

Chapter 2. Binary Values and Number Systems

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

3. Convert a number from one number system to another

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

Useful Number Systems

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

Section 1.4 Place Value Systems of Numeration in Other Bases

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Computer Science 281 Binary and Hexadecimal Review

Binary Representation

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Binary Numbers. Binary Octal Hexadecimal

Binary, Hexadecimal, Octal, and BCD Numbers

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

Numeration systems. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Chapter 4: Computer Codes

2011, The McGraw-Hill Companies, Inc. Chapter 3

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

The string of digits in the binary number system represents the quantity

COMPSCI 210. Binary Fractions. Agenda & Reading

A Step towards an Easy Interconversion of Various Number Systems

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

NUMBER SYSTEMS. William Stallings

=

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Numbering Systems. InThisAppendix...

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

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Chapter 1: Digital Systems and Binary Numbers

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Solution for Homework 2

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Lecture 2. Binary and Hexadecimal Numbers

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Number Systems and Radix Conversion

Number Systems. Introduction / Number Systems

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Verilog - Representation of Number Literals

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix:

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Math Circle Beginners Group October 18, 2015

CS321. Introduction to Numerical Methods

Systems I: Computer Organization and Architecture

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Positional Numbering System

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Binary Adders: Half Adders and Full Adders

Grade 6 Math Circles. Binary and Beyond

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

CS201: Architecture and Assembly Language

Unit 6 Number and Operations in Base Ten: Decimals

Memory Management Simulation Interactive Lab

CHAPTER 5 Round-off errors

Number and codes in digital systems

Accuplacer Arithmetic Study Guide

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

BINARY CODED DECIMAL: B.C.D.

Unit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.

MACHINE INSTRUCTIONS AND PROGRAMS

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

6 The Hindu-Arabic System (800 BC)

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Activity 1: Using base ten blocks to model operations on decimals

HOMEWORK # 2 SOLUTIO

Solutions of Linear Equations in One Variable

Number Representation

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Take-Home Exercise. z y x. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

Prerequisite knowledge Students should have a good understanding of how our decimal number system works as well as understand place value.

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

2.3 IPv4 Address Subnetting Part 2

Counting in base 10, 2 and 16

Asynchronous counters, except for the first block, work independently from a system clock.

The Subnet Training Guide

26 Integers: Multiplication, Division, and Order

3.4. The Binomial Probability Distribution. Copyright Cengage Learning. All rights reserved.

Data Storage. 1s and 0s

Decimal to Binary Conversion

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Preliminary Mathematics

Chapter 1. Binary, octal and hexadecimal numbers

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID.

Zeros of a Polynomial Function

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

118 One hundred Eighteen

Transcription:

Number Systems Introduction & Objectives: Before the inception of digital computers, the only number system (النظام العشري) that was in common use is the decimal number system which has a total of 10 digits (0 to 9). As discussed in the previous lesson, signals in digital computers may represent a digit in some number system. It was also found that the binary number system is more reliable to use compared to the more familiar decimal system In this lesson, you will learn: What is meant by a weighted number system. Basic features of weighted number systems. Commonly used number systems, e.g. decimal, binary, octal and hexadecimal. Important properties of these systems.

Weighted Number Systems: A number D consists of n digits with each digit has a particular position. D = d n-1 d n-2.. d 2 d 1 d 0 Position n-1 Position 2 Position 1 Position 0 Every digit position is associated with a fixed weight. If the weight associated with the i th. position is w i, then the value of D is given by: D = d n-1 w n-1 + d n-2 w n-2 + + d 2 w 2 + d 1 w 1 + d 0 w 0 Example of Weighted Number Systems: The Decimal number system ( العشري (النظام is a weighted system. For Integer decimal numbers, the weight of the rightmost digit (at position 0) is 1, the weight of position 1 digit is 10, that of position 2 digit is 100, position 3 is 1000, etc.

Thus, w 0 = 1, w 1 = 10, w 2 =100, w 3 = 1000, etc. Example Show how the value of the decimal number 9375 is estimated First Position Index Position 3 2 1 0 First Position Index (0) Number 9 3 7 5 Weight 1000 100 10 1 Value 9 x 1000 3x100 7x10 5x1 Value 9000 + 300 + 70 + 5 The Radix (Base) 1. For digit position i, most weighted number systems use weights (w i ) that are powers of some constant value called the radix (r) or the base such that w i = r i. 2. A number system of radix r, typically has a set of r allowed digits {0,1,,(r-1)} See the next example 3. The leftmost digit has the highest weight Most Significant Digit (MSD) See the next example 4. The rightmost digit has the lowest weight Least Significant Digit (LSD) See the next example

Example Decimal Number System 1. Radix (Base) = Ten 2. Since w i = r i., then w 0 = 10 0 = 1, w 1 = 10 1 = 10, w 2 = 10 2 = 100, w 3 = 10 3 = 1000, etc. 3. Number of Allowed Digits is Ten {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Thus: MSD LSD 9375 = 5x10 0 + 7x10 1 + 3x10 2 + 9x10 3 = 5x1 + 7x10 + 3x100 + 9x 1000 Position 3 2 1 0 1000 100 10 1 Weight = 10 3 = 10 2 = 10 1 = 10 0 The Radix Point Consider a number system of radix r, A number D of n integral digits and m fractional digits is represented as shown

Digits to the left of the radix point (integral digits) have positive position indices, while digits to the right of the radix point (fractional digits) have negative position indices Position indices of digits to the left of the radix point (the integral part of D) start with a 0 and are incremented as we move lefts (d n-1 d n-2..d 2 d 1 d 0. ) Position indices of digits to the right of the radix point (the fractional part of D) are negative starting with 1 and are decremented as we move rights ( d -1 d -2..d -m ). The weight associated with digit position i is given by w i = r i, where i is the position index i= -m, -m+1,, -2, -1, 0, 1,, n-1 The Value of D is Computed as : D = n 1 i = m d i r i

Example estimated Show how the value of the following decimal number is D = 5 2. 9 4 6 d 1 d 0. d -1 d -2 d -3 Number 5 2. 9 4 6 Position 1 0. -1-2 -3 Weight Value 10 1 = 10 5 x 10 10 0 = 1 2 x 1.. 10-1 = 0.1 9 x 0.1 10-2 = 0.01 2 x 0.01 10-3 = 0.001 6 x 0.001 Value 50 + 2 + 0.9 +0.02 +0.006 Notation D = 5x10 1 + 2x10 0 + 9x10-1 + 4x10-2 + 6x10-3 Let (D) r denotes a number D expressed in a number system of radix r. Note: In this notation, r will be expressed in decimal Example: (29) 10 Represents a decimal value of 29. The radix 10 here means ten. (100) 16 is a Hexadecimal number since r = 16 here means sixteen. This number is equivalent to a decimal value of 16 2. (100) 2 is a Binary number (radix =2, i.e. two) which is equivalent to a decimal value of 2 2 = 4.

Important Number Systems The Decimal System r = 10 (ten Radix is not a Power of 2) Ten Possible Digits {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} The Binary System r = 2 Two Allowed Digits {0, 1} A Binary Digit is referred to as Bit The leftmost bit has the highest weight Most Significant Bit (MSB) The rightmost bit has the lowest weight Least Significant Bit (LSB) Examples Find the decimal value of the two Binary numbers (101) 2 and (1.101) 2 MSB LSB ( 1 0 1 ) 2 = 1x2 0 + 0x2 1 + 1x2 2 = 1x1 + 0x2 + 1x 4 = ( 5 ) 10 MSB LSB (1. 1 0 1 ) 2 = 1x2 0 + 1x2-1 + 0x2-2 + 1x2-3 = 1 + 0.5 + 0.25 + 0.125 = ( 1. 8 7 5 ) 10

Octal System: r = 8 (Eight = 2 3 ) Eight Allowed Digits {0, 1, 2, 3, 4, 5, 6, 7} Examples Find the decimal value of the two Octal numbers (375 ) 8 and (2.746 ) 8 MSD LSD ( 375 ) 8 = 5x8 0 + 7x8 1 + 3x8 2 = 5x1 + 7x8 + 3x64 = ( 253 ) 10 MSD LSD (2.746 ) 8 = 2x8 0 + 7x8-1 + 4x8-2 + 6x8-3 = (2.94921875 ) 10 Hexadecimal System: r = 16 (Sixteen = 2 4 ) Sixteen Allowed Digits {0-to-9 and A, B, C, D, E, F} o Where: A = ten, B = Eleven, C = Twelve, D = Thirteen, E = Fourteen & F = Fifteen. Q: Why is the digit following 9 assigned the character A and not 10? A: What we need is a single digit whose value is ten, but 10 is actually two digits not one. o Thus, in Hexadecimal system the 2-digit number (10) 16 actually represents a value of sixteen not ten {(10) 16 = 0x16 0 + 1x16 1.=(16) 10 }.

Examples Find the decimal value of the two Hexadecimal numbers (9E1) 16 and (3B.C ) 16 MSD LSD (9E1) 16 = 1x16 0 + Ex16 1 + 9x16 2 = 1x1 + 14x16 + 9x256 = ( 2529 ) 10 MSD LSD (3B.C ) 16 = Cx16-1 + Bx16 0 + 3x16 1 = 12x16-1 + 11x16 0 + 3x16 = (59.75 ) 10 Important Properties 1. The number of possible digits in any number system with radix r equals r. (Give examples in decimal, binary, octal and hexadecimal) 2. The smallest digit is 0 and the largest possible digit has a value = (r-1) 3. The Largest value that can be expressed in n integral digits is (r n -1) Prove (Hint add 1 to the LSD position of the largest number) 4. The Largest value that can be expressed in m fractional digits is (1-r -m ) Prove (Hint add 1 to the LSD position of the largest number) 5. The Largest value that can be expressed in n integral digits and m fractional digits is (r n -r -m ) Prove (Hint- add results of properties 3 &4 above) 6. Total number of values (patterns) representable in n digits is r n

Clarification (a) Q. What is the result of adding 1 to the largest digit of some number system?? A. For the decimal number system, (1) 10 + (9) 10 = (10) 10 For the octal number system, (1) 8 + (7) 8 = (10) 8 = (8) 10 For the hex number system, (1) 16 + (F) 16 = (10) 16 = (16) 10 For the binary number system, (1) 2 + (1) 2 = (10) 2 = (2) 10 Conclusion. Adding 1 to the largest digit in any number system always has a result of (10) in that number system.

This is easy to prove since the largest digit in a number system of radix r has a value of (r-1). Adding 1 to this value the result is r which is always equal to (10) r = 0x r 0 + 1x r 1 =(r) 10 Clarification (b) Q. What is the largest value representable in 3-integral digits? A. The largest value results when all 3 positions are filled with the largest digit in the number system. ------------------------------------------------------------- For the decimal system, it is (999) 10 For the octal system, it is (777) 8 For the hex system, it is (FFF) 16 For the binary system, it is (111) 2 ------------------------------------------------------------- Clarification (c) Q. What is the result of adding 1 to the largest 3-digit number?? A. For the decimal system, (1) 10 + (999) 10 = (1000) 10 = (10 3 ) 10 For the octal system, (1) 8 + (777) 8 = (1000) 8 = (8 3 ) 10

For the hex system, (1) 16 + (FFF) 16 = (1000) 16 = (16 3 ) 16 For the binary system, (1) 2 + (111) 2 = (1000) 2 = (2 3 ) 10 In general, for a number system of radix r, adding 1 to the largest n-digit number = r n

Accordingly, the value of largest n-digit number = r n -1 Conclusions. 1. In any number system of radix r, the result of adding 1 to the largest n-digit number equals r n. 2. Thus, the value of the largest n-digit number is equal to (r n -1) 3. Thus, n digits can represent r n different values (digit combinations) starting from a 0 value up to the largest value of r n -1.

Appendix A. Summary of Number Systems Properties The following table summarizes the basic features of the Decimal, Octal, Binary, and Hexadecimal number systems as well as a number system with a general radix r Allowed Digits Value of a n-1 a 2 a 1 a 0. a -1 a -2.a -m Smallest n- digit number Largest n- digit number Range of n- digit integers # of Possible Combinations of n-digits Max Value of m Fractional Digits Decimal 10 {0-9} a n-1 x10 n-1 + a n-2 x10 n-2 +...+ a 2 x10 2 + a 1 x10 1 + a 0 x 10 0 + a -1 x 10-1 + a -2 x10-2 +..+ a -m x10 -m a i {0-9} i=-m,., 0, 1,, n-1 000..0 999 9 = 10 n 1 0 - (10 n -1) 10 n 1-10 -m Octal 8 {0-7} a n-1 8 n-1 + + a 2 8 2 +a 1 8 1 +a 0 8 0 +a -1 8-1 + a -2 8-2 +.+a -m 8 -m a i {0-7} 000..0 77..7 = 8 n 1 0- (8 n -1) 8 n 1-8 -m Binary 2 {0-1} a n-1 2 n-1 + + a 2 2 2 +a 1 2 1 +a 0 2 0 +a -1 2-1 + a -2 2-2 +.+a -m 2 -m a i {0,1} 000..0 11..1 = 2 n 1 0- (2 n -1) 2 n 1-2 -m Hexadeci mal 16 {0-9, A-F} 000..0 FF.F = 16 n 1 0- (16 n -1) 16 n 1-16 -m General r { 0 - R} where R = (r-1) a n-1 r n-1 + + a 2 r 2 + a 1 r 1 + a 0 r 0 + a -1 r -1 + a -2 r -2 +.+a -m r -m a i {0 - (r-1)} 000..0 RR..R = r n 1 0 (r n 1) r n 1-r -m 1

Appendix B. First 16 Binary Numbers & Their Decimal Equivalent (All Possible Binary Combinations in 4-Bits) Decimal Bin. Equivelent Decimal Bin. Equivelent 0 0000 8 1000 1 0001 9 1001 2 0010 10 1010 3 0011 11 1011 4 0100 12 1100 5 0101 13 1101 6 0110 14 1110 7 0111 15 1111 2

Appendix C. Decimal Values of the First 10 Powers of 2 One Kilo is defined as 1000. For example, one Kilogram is 1000 grams. A kilometer is 1000 meters. In the Binary system, the power of 2 value closest to 1000 is 2 10 which equals 1024. This is referred to as one Kilo (or in short 1K) in binary systems. Thus, one Kilo (or 1K) in Binary systems is not exactly 1000 but rather equals 1024 or 2 10 Thus, in binary systems 2K= 2 x 1024 = 2048, 4K=4 x 1024= 4096, and so on Similarly, a one Meg (one million) in binary systems is 2 20 which equals 1,048,576. 1 Kilo = 1K 2K = 2048 4K = 4096 3 Powers of 2 Decimal. Value 2 0 1 2 1 2 2 2 4 2 3 8 2 4 16 2 5 32 2 6 64 2 7 128 2 8 256 2 9 512 2 10 1024