3. Convert a number from one number system to another



Similar documents
NUMBER SYSTEMS. 1.1 Introduction

Lecture 11: Number Systems

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

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

Base Conversion written by Cathy Saxton

Useful Number Systems

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

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

CSI 333 Lecture 1 Number Systems

CPEN Digital Logic Design Binary Systems

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

THE BINARY NUMBER SYSTEM

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

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

Decimal to Binary Conversion

COMPSCI 210. Binary Fractions. Agenda & Reading

Binary, Hexadecimal, Octal, and BCD Numbers

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

Number and codes in digital systems

Chapter 2. Binary Values and Number Systems

Positional Numbering System

Binary Numbers. Binary Octal Hexadecimal

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

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

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

Number Systems. Introduction / Number Systems

=

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

Binary Representation

Section 1.4 Place Value Systems of Numeration in Other Bases

NUMBER SYSTEMS. William Stallings

A Step towards an Easy Interconversion of Various Number Systems

Numbering Systems. InThisAppendix...

Computer Science 281 Binary and Hexadecimal Review

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

CS201: Architecture and Assembly Language

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

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

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

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

Paramedic Program Pre-Admission Mathematics Test Study Guide

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

Number Representation

Lecture 2. Binary and Hexadecimal Numbers

Systems I: Computer Organization and Architecture

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Number Systems and Radix Conversion

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

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

BINARY CODED DECIMAL: B.C.D.

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

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

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

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

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

Lecture 8: Binary Multiplication & Division

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

ADDITION. Children should extend the carrying method to numbers with at least four digits.

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Chapter 1: Digital Systems and Binary Numbers

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

PREPARATION FOR MATH TESTING at CityLab Academy

COMBINATIONAL CIRCUITS

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

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

MATH-0910 Review Concepts (Haugen)

Solution for Homework 2

Decimals Adding and Subtracting

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

INTRODUCTION TO FRACTIONS

Number of bits needed to address hosts 8

Subnetting Examples. There are three types of subnetting examples I will show in this document:

Fractions to decimals

Logic Reference Guide

Math Circle Beginners Group October 18, 2015

Addition Methods. Methods Jottings Expanded Compact Examples = 15

Chapter 4 -- Decimals

CS321. Introduction to Numerical Methods

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

MACM 101 Discrete Mathematics I

DIVISION OF DECIMALS We then we multiply by the

Partial Fractions. Combining fractions over a common denominator is a familiar operation from algebra:

6 The Hindu-Arabic System (800 BC)

Partial Fractions. p(x) q(x)

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.

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

Verilog - Representation of Number Literals

Cyber Security Workshop Encryption Reference Manual

Sequential Skills. Strands and Major Topics

3.4 Multiplication and Division of Rational Numbers

3 cups ¾ ½ ¼ 2 cups ¾ ½ ¼. 1 cup ¾ ½ ¼. 1 cup. 1 cup ¾ ½ ¼ ¾ ½ ¼. 1 cup. 1 cup ¾ ½ ¼ ¾ ½ ¼

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

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

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

Pre-Calculus II Factoring and Operations on Polynomials

Playing with Numbers

The Euclidean Algorithm

Math Workshop October 2010 Fractions and Repeating Decimals

Counting in base 10, 2 and 16

ELEG3924 Microprocessor Ch.7 Programming In C

Transcription:

3. Convert a number from one number system to another Conversion between number bases: Hexa (16) Decimal (10) Binary (2) Octal (8) More Interest Way we need conversion? We need decimal system for real world (for presentation and input): for example: we use 10-based numbering system for input and output in digital calculator. We need binary system inside calculator for calculation. Input Conversion 10-to-2 Digital System Conversion 2-to-10 Output

a) Binary to decimal conversions: Rule: any binary number can be converted to its decimal equivalent simply by summing together the weights of the various positions in the binary number which contains a 1. Example 1: Convert 11011 2 to its decimal equivalent 1 1 0 1 1 + + + = 16+8+2+1= 27 10 2 4 +2 3 0 2 1 2 0 Example 2: Convert 10110101 2 to decimal equivalent 2 7 + 0+ 2 5 + 2 4 + 0+ 2 2 + 0+ 2 0 = 181 10 b) Decimal to binary conversions: There are two ways to convert a decimal number to its equivalent binary representation 1. The reverse of the binary-to-decimal conversion process (optional). The decimal number is simply expressed as a sum of powers of 2 and then 1 2 and 0 2 are written in the appropriate bit positions. Example 1:-Convert 45 10 to binary number 45 10 = 32+ 8+ 4+ 1= 2 5 + 0+ 2 3 + 2 2 + 0+ 2 0 =101101 (2) Example 2:-Convert 76 10 to binary number 76 10 = 64+ 8+ 4 = 2 6 + 2 3 + 2 2 = 1001100 2 2. Repeated division: Repeating division the decimal number by 2 and writing down the remainder after each division until a quotient of 0 is obtained. Note: The binary result is obtained by writing the first remainder as the LSB and the last remainder as the MSB. General Rule 1: Conversion from decimal to other base 1. Divide decimal number by the base (2, 8, 16, ). 2. The remainder is the lowest-order digit. 3. Repeat first two steps unit no divisor remains.

General Rule 2: Decimal fraction conversion to anther base 1. Multiply decimal number by the base (2, 8, ). 2. The integer is the highest-order digit. 3. Repeat first two steps until fraction becomes zero. Example 1 Convert 25 10 to binary number = 12 + remainder of 1 (LSB) = 6 + remainder of 0 = 3 + remainder of 0 = 1 + remainder of 1 = 0 + remainder of 1 (MSB) 25 10 = 1 1 0 0 1 2 Example 2 Convert 13 10 to binary number Division by 2 Quotient integer remainder 6 1 (a 0 ) = 3 0 (a 1 ) 1 1 (a 2 ) 0 1 (a 3 ) Answer (13) 10 = (a 3 a 2 a 1 a 0 ) = (1101) 2

Example 3: Convert 0.625 10 to binary number Multiply by 2 Integer Fraction coefficient 0.625*2 = 1 + 0.25 a 1 = 1 0.250*2 = 0 + 0.50 a 2 = 0 0.500*2 = 1 + 0(stop) a 3 = 1 Answer (0.625) 10 = (0.a 1 a 2 a 3 ) 2 = (0.101) 2 Correct order c) Octal-to-decimal To convert, we need to multiply each octal digit by its positional weight. Example 1 372 (8) = (3*8 2 ) + (7*8 1 ) + (2*8 0 ) = (3*64) + 56+2 = 250 10 Example 2 24.6 8 = (2*8 1 ) + (4*8 0 ) + (6*8-1 ) = 20.75 10 d) Decimal to octal Repeated division by 8. Example 1: Convert 266 10 to octal number. = 33 + remainder of 2 (LSD) = 4 + remainder of 1 = 0 + remainder of 4 266 10 = 4 1 2 (8)

Example 2: Convert 0.35 10 to octal number. Multiply by 8 Integer Fraction coefficient 0.35*8= 2 + 0.80 a 1 = 2 Repeated stop 0.8*8 = 6 + 0.40 a 2 = 6 0.4*8 = 3 + 0.20 a 3 = 3 0.2*8 = 1 + 0.60 a 4 =1 0.6*8 = 4 + 0.80 a 5 =4 Answer (0.35) 10 = (0.a 1 a 2 a 3 a 4 a 5 ) 2 = (0.26314) 8 Correct order e) Hexa-to-decimal Example 1:-Convert 356 (16) to decimal: 356 (16) = (3*16 2 ) + (5*16 1 ) + (6*16 0 ) = 3*256 + 80 +6 = 854 (10) Example 2:-Convert 2AF (16) to decimal: 2AF (16) = (2*16 2 ) + (10*16 1 ) + (15*16 0 ) = 512+160+15 = 687 (10) f) Decimal-to-hexa:(using repeated division by 16) Example 1: Convert 423 10 to hex number. = 26 + remainder of 7 (LSD) = 1 + remainder of 10 = 0 + remainder of 1 423 10 = 1 A 7 (16)

g) Hexa-to-binary: Each hexa digit is converted to its four-bit binary equivalent: Example 1: Convert 9F2 (16) to its binary equivalent 9 F 2 1001 1111 0010 9F2 (16) = 100111110010 (2) Example 2: Convert BA6 (16) to binary equivalent BA6 (16) = (1011 1010 0110) 2 h) Binary-to-hexa The binary numbers are grouped into groups of four bits and each group is converted to its equivalent hexa digit. Zeros are added as needed to complete a four-bit group. Example 1: Convert 1110100110 (2) to hexa equivalent Added zeros 0011 1010 0110 3 A 6 1110100110 (2) = 3A6 (16) Example 2: Convert 101011111 2 to hexa equivalent 1 0101 1111 2 = 15F (16) i) Octal to binary conversion: Conversion each octal digit to its three bit binary equivalent. Conversion Table Octal digit 0 1 2 3 4 5 6 7 Binary 000 001 010 011 100 101 110 111 equivalent

Using this table, we can convert any octal number to binary by individually converting each digit. Example 1: Convert 472 (8) to binary number 4 7 2 100 111 010 472 (8)) = 100111010 (2) Example 2: Convert 5431 (8) to binary number 5431 (8) = 101 100 011 001 = 101100011001 (2) j) Binary to octal conversion: The bits of the binary number are grouped into group of 3 bits starting at the LSB, then each group is converted to its octal equivalent (see table). Example 1: Convert 11010110 (2) to octal equivalent Added zero 011 010 110 3 2 6 11010110 (2) = 326 (8) Note: Zero was placed to the left of the MSB to produce groups of 3 bits. General example: Convert 177 10 to its eight-bit binary equivalent by first converting to octal.

= 22 + remainder of 1 (LSD) = 2 + remainder of 6 = 0 + remainder of 2 177 10 = 2 6 1 (8) Thus 177 10 = 261 (8), now we can quickly convert this octal number to its binary equivalent 010110001 to get eight bit representation. So: Important Note: this method of decimal-to-octal-to-binary conversion is often quicker than going directly from decimal to binary, especially for large numbers. 4. Advantage of octal and hexadecimal systems: 1. Hexa and octal number are used as a "short hand" way to represent stings of bits. 2. Error prone to write the binary number, in hex and octal less error. 3. The octal and hexadecimal number systems are both used (in memory addressing and microprocessor technology).