Positional Numbering System



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

CSI 333 Lecture 1 Number Systems

Useful Number Systems

Decimal to Binary Conversion

NUMBER SYSTEMS. William Stallings

Computer Science 281 Binary and Hexadecimal Review

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

NUMBER SYSTEMS. 1.1 Introduction

Section 1.4 Place Value Systems of Numeration in Other Bases

Base Conversion written by Cathy Saxton

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

=

THE BINARY NUMBER SYSTEM

Lecture 11: Number Systems

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

3. Convert a number from one number system to another

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

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

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Binary, Hexadecimal, Octal, and BCD Numbers

Chapter 2. Binary Values and Number Systems

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

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.

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

CPEN Digital Logic Design Binary Systems

Chapter 4. IP Addresses: Classful Addressing

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

6 The Hindu-Arabic System (800 BC)

Cyber Security Workshop Encryption Reference Manual

Number Systems and Radix Conversion

Chapter 4 IP Addresses: Classful Addressing

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

Lecture 2. Binary and Hexadecimal Numbers

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

Binary Representation

Lecture 8: Binary Multiplication & Division

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

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

COMPSCI 210. Binary Fractions. Agenda & Reading

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

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

IT:101 Cisco Networking Academy I Subnetting

Number Systems. Introduction / Number Systems

Math Circle Beginners Group October 18, 2015

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

Paramedic Program Pre-Admission Mathematics Test Study Guide

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

YOU MUST BE ABLE TO DO THE FOLLOWING PROBLEMS WITHOUT A CALCULATOR!

Chapter 5. IPv4 Addresses. TCP/IP Protocol Suite 1 Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Chapter 4 -- Decimals

Math Workshop October 2010 Fractions and Repeating Decimals

PREPARATION FOR MATH TESTING at CityLab Academy

MACM 101 Discrete Mathematics I

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

MULTIPLICATION AND DIVISION OF REAL NUMBERS In this section we will complete the study of the four basic operations with real numbers.

3.1. RATIONAL EXPRESSIONS

Number Representation

Number of bits needed to address hosts 8

CE363 Data Communications & Networking. Chapter 6 Network Layer: Logical Addressing

CS321. Introduction to Numerical Methods

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

Decimal Notations for Fractions Number and Operations Fractions /4.NF

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Grade 6 Math Circles. Binary and Beyond

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

Section IV.1: Recursive Algorithms and Recursion Trees

Preliminary Mathematics

A Step towards an Easy Interconversion of Various Number Systems

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Multiplication. Year 1 multiply with concrete objects, arrays and pictorial representations

The gas can has a capacity of 4.17 gallons and weighs 3.4 pounds.

A Prime Investigation with 7, 11, and 13

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

3201 Computer Networks 2014/2015 Handout: Subnetting Question

Welcome to Math Video Lessons. Stanley Ocken. Department of Mathematics The City College of New York Fall 2013

2.3 IPv4 Address Subnetting Part 2

Streaming Lossless Data Compression Algorithm (SLDC)

Solution Guide Chapter 14 Mixing Fractions, Decimals, and Percents Together

Memory is implemented as an array of electronic switches

Chapter 4: Computer Codes

Binary Numbers. Binary Octal Hexadecimal

Counting in base 10, 2 and 16

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

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points.

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

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

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

Radicals - Multiply and Divide Radicals

MATHEMATICAL NOTATION COMPARISONS BETWEEN U.S. AND LATIN AMERICAN COUNTRIES

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Chapter 5. Binary, octal and hexadecimal numbers


Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Zeros of Polynomial Functions

The BBP Algorithm for Pi

Grade 6 Mathematics Assessment. Eligible Texas Essential Knowledge and Skills

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

Systems I: Computer Organization and Architecture

Transcription:

APPENDIX B Positional Numbering System A positional numbering system uses a set of symbols. The value that each symbol represents, however, depends on its face value and its place value, the value associated with the position it occupies in the number. In other words, we have the following. Symbol value = Face value Place value Number value = Sum of Symbol values In this appendix, we discuss only integers, numbers with no fractional part; the discussion of reals, numbers with a fractional part, is similar. B.1 DIFFERENT SYSTEMS We first show how integers can be represented in four different systems: base 10, base 2, base 16, and base 256. B.1.1 Base 10: Decimal The first positional system we discuss is called the decimal system. The term decimal is derived from the Latin root decem (meaning ten). The decimal system uses 10 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) with the same face values as the symbols. The place values in the decimal number system are powers of 10. Figure B.1 shows the place values and the symbol values in the integer 4782. Figure B.1 An example of a decimal number 10 3 10 2 10 1 10 0 4 7 8 2 4000 + 700 + 80 + 2 4782 Place values Symbols Symbol values Number value The decimal system uses 10 symbols in which the place values are powers of 10. B-1

B-2 APPENDIX B POSITIONAL NUMBERING SYSTEM B.1.2 Base 2: Binary The second positional system we discuss is called the binary system. The term binary is derived from the Latin root bi (meaning two by two). The binary system uses 2 symbols (0 and 1) with the same face values as the symbols. The place values in the binary number system are powers of 2. Figure B.2 shows the place values and the symbol values in the binary (1101) 2. Note that we use subscript 2 to show that the number is in binary. Figure B.2 An example of a binary number 2 3 2 2 2 1 2 0 1 1 0 1 8 + 4 + 0 + 1 13 Place values Symbols Symbol values Number value (in decimal) The binary system uses 2 symbols in which the place values are powers of 2. B.1.3 Base 16: Hexadecimal The third positional system we discuss is called the hexadecimal system. The term hexadecimal is derived from the Greek root hex (meaning 6) and the Latin root decem (meaning ten). The hexadecimal system uses 16 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F). The face value of the first ten symbols are the same as the symbols, but the face values of the symbols A to F are 10 to 15 respectively. The place values in the hexadecimal number system are powers of 16. Figure B.3 shows the place values and the symbol values in the hexadecimal (A20E) 16. Note that we use subscript 16 to show that the number is in hexadecimal. Figure B.3 An example of a hexadecimal number 16 3 16 2 16 1 16 0 A 2 0 E 40,960 + 512 + 0 + 14 41,486 Place values Symbols Symbol value (in decimal) Number value (in decimal) The hexadecimal system uses 16 symbols in which the place values are powers of 16.

APPENDIX B POSITIONAL NUMBERING SYSTEM B-3 B.1.4 Base 256: Dotted-Decimal Notation The fourth positional system we discuss is base 256, which is called dotted-decimal notation. This system is used to represent IPv4 addressing. The place values in this system are powers of 256. However, since using 256 symbols is almost impossible, the symbols in this system are decimal numbers between 0 and 255, with the same face values as the symbols. To separate these numbers from each other, the system uses a dot, as discussed in Chapter 18. Figure B.4 shows the place values and the symbol values of the address (14.18.111.252). Note that we never use more than four symbols in an IPv4 address. Figure B.4 An example of a dotted-decimal notation 256 3 111 14 234,881,024 + 256 2 256 1 256 0 18 252 1,179,648 + 28,416 + 252 236,089,340 Place values Symbols Symbol values Number value (in decimal) Dotted-decimal notation uses decimal numbers (0 to 255) as symbols, but inserts a dot between each symbol. B.1.5 Comparison Table B.1 shows how three different systems represent the decimal numbers 0 through 15. For example, decimal 13 is equivalent to binary (1101) 2, which is equivalent to hexadecimal D. Table B.1 Comparison of three systems Decimal Binary Hexadecimal Decimal Binary Hexadecimal 0 0000 0 8 1000 8 1 0001 1 9 1001 9 2 0010 2 10 1010 A 3 0011 3 11 1011 B 4 0100 4 12 1100 C 5 0101 5 13 1101 D 6 0110 6 14 1110 E 7 0111 7 15 1111 F B.2 CONVERSION We need to know how to convert a number in one system to the equivalent number in another system.

B-4 APPENDIX B POSITIONAL NUMBERING SYSTEM B.2.1 Conversion from Any Base to Decimal Figures B.2 to B.4 actually show how we can manually convert a number in any base to decimal. However, it is easier to use the algorithm in Figure B.5. The algorithm uses the fact that the next place value is the previous value multiplied by the base (2, 16, or 256). The algorithm is a general one that can be used to convert a string of symbols in a given base to a decimal number. The only section in the algorithm that is different for each base is how to extract the next symbol in the string and find its face value. In the case of base 2, it is simple: the face value can be found by changing the symbol to a numeric value. In the case of base 16, we need to consider the case that the face value of symbol A is 10, the face value of symbol B is 11, and so on. In the case of base 256, we need to extract each string delimited by dots and change the string to its numerical value. Figure B.5 Algorithm to convert from any base to decimal Given string and base PV: Place value FV: Face value SV: Symbol value Decimal = 0 PV = 1 PV = PV base Decimal = Decimal + SV SV = FV PV Extract face value of next symbol [Yes] [No] More symbols in string Return decimal The manual implementation of the above algorithm for small numbers can be shown in a few examples. Example B.1 Show the equivalent of the binary number (11100111) 2 in decimal. We follow the algorithm as shown below. 128 64 32 16 8 4 2 1 Place values 1 1 1 0 0 1 1 1 Face values 128 64 32 0 0 4 2 1 Symbol values 231 103 39 7 7 7 3 1 Decimal = 0

APPENDIX B POSITIONAL NUMBERING SYSTEM B-5 The value of decimal is initially set to 0. When the loop is terminated, the value of decimal is 231. Example B.2 Show the equivalent of the IPv4 address 12.14.67.24 in decimal. We follow the algorithm as shown below. 16,777,216 65,536 256 1 Place values 12 14 67 24 Face values 201,326,592 917,504 17,152 24 Symbol values 202,261,272 934,680 17,176 24 Decimal = 0 The value of decimal is initially set to 0. When the loop is terminated, the value of decimal is 202,261,272. B.2.2 Conversion from Decimal to Any Base Conversion from a decimal value to any base can be done if we continuously divide the decimal number by the base to find the remainder and the quotient (see Figure B.6). The remainder is the face value of the next symbol; the quotient is the decimal value to be used in the next iteration. As in the case of inverse conversion, we need to have a separate algorithm to change the face value of a symbol, in the corresponding base, to the actual symbol and insert it in the string representing the converted number. Figure B.6 Conversion from decimal to any base FV: Face value of symbol %: Remainder operator /: Quotient operator Create an empty string. Given decimal and base Convert FV to the symbol and insert it into string decimal = decimal / base FV = decimal % base [No] [Yes] Decimal is zero? Return the string

B-6 APPENDIX B POSITIONAL NUMBERING SYSTEM We can show how we can manually follow the algorithm in a few examples. Example B.3 Convert the decimal number 25 to its binary equivalent. We continuously divide the decimal value by 2 (the base of the binary system) until the quotient becomes 0. In each division we interpret the value of the remainder as the next symbol to be inserted in the hexadecimal string. The down arrow shows the remainder; the left arrow shows the quotient. When the decimal value becomes 0, we stop. The result is the binary string (11001) 2. 0 1 3 6 12 25 Decimal 1 1 0 0 1 Binary Example B.4 Convert the decimal number 21,432 to its hexadecimal equivalent. We continuously divide the decimal value by 16 (the base of the hexadecimal system) until the quotient becomes 0. In each division we interpret the value of the remainder as the next symbol to be inserted in the hexadecimal string. The result is the hexadecimal string (53B8) 16. 0 5 83 1339 21432 Decimal 5 3 B 8 Hexadecimal Example B.5 Convert the decimal number 73,234,122 to base 256 (IPv4 address). We continuously divide the decimal value by 256 (the base) until the quotient becomes 0. In each division we interpret the value of the remainder as the next symbol to be inserted in the IPv6 address. We also insert dots as required in the dotted-decimal notation. The result is the IPv4 address 4.93.118.202. 0 4 1117 286,070 73,234,122 Decimal 4 93 118 202 IPv4 address

APPENDIX B POSITIONAL NUMBERING SYSTEM B-7 B.2.3 Other Conversions Conversion from a nondecimal system to another nondecimal system is often easier. We can easily convert a number in binary to hexadecimal by converting a group of 4 bits into 1 hexadecimal digit. We can also convert a hexadecimal digit into a group of 4 bits. We give a few examples to show the process. Example B.6 Convert the binary number (1001111101) 2 to its equivalent in hexadecimal. We create groups of 4 bits from the right. We then replace each group with its equivalent hexadecimal digit. Note that we need to add two extra 0s to the last group. 0010 0111 1101 Binary 2 7 D Hexadecimal The result is (27D) 16. Example B.7 Convert the hexadecimal number (3A2B) 16 to its equivalent in binary. We change each hexadecimal digit to its 4-bit binary equivalent. 3 A 2 B Hexadecimal 0011 1010 0010 1011 Binary The result is (0011 1010 0010 1011) 2. Example B.8 Convert the IPv4 address 112.23.78.201 to its binary format. We replace each symbol with its equivalent 8-bit binary. 112 23 78 201 IPv4 address 01110000 00010111 01001110 11001001 Binary The result is (01110000 00010111 01001110 11001001) 2.