Unsigned Conversions from Decimal or to Decimal and other Number Systems



Similar documents
Useful Number Systems

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

Computer Science 281 Binary and Hexadecimal Review

CSI 333 Lecture 1 Number Systems

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

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

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

CPEN Digital Logic Design Binary Systems

Lecture 11: Number Systems

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

Positional Numbering System

NUMBER SYSTEMS. 1.1 Introduction

Lecture 2. Binary and Hexadecimal Numbers

Section 1.4 Place Value Systems of Numeration in Other Bases

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Decimal to Binary Conversion

NUMBER SYSTEMS. William Stallings

THE BINARY NUMBER SYSTEM

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

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

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

=

COMPSCI 210. Binary Fractions. Agenda & Reading

Binary, Hexadecimal, Octal, and BCD Numbers

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

Numbering Systems. InThisAppendix...

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

Binary Representation

3. Convert a number from one number system to another

Binary Numbers. Binary Octal Hexadecimal

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

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

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

Number Representation

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

Systems I: Computer Organization and Architecture

Number Systems. Introduction / Number Systems

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

A Step towards an Easy Interconversion of Various Number Systems

Chapter 1: Digital Systems and Binary Numbers

Chapter 2. Binary Values and Number Systems

Chapter 1. Binary, octal and hexadecimal numbers

Chapter 4: Computer Codes

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

Memory Management Simulation Interactive Lab

The Hexadecimal Number System and Memory Addressing

Number Systems and Radix Conversion

Verilog - Representation of Number Literals

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

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

Solution for Homework 2

Number of bits needed to address hosts 8

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

CHAPTER 5 Round-off errors

CS321. Introduction to Numerical Methods

Memory is implemented as an array of electronic switches

HOMEWORK # 2 SOLUTIO

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

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

Chapter 5. Binary, octal and hexadecimal numbers

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

PURSUITS IN MATHEMATICS often produce elementary functions as solutions that need to be

Number and codes in digital systems

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

Counting in base 10, 2 and 16

Radicals - Square Roots

The Answer to the 14 Most Frequently Asked Modbus Questions

Binary Adders: Half Adders and Full Adders

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

Lecture 8: Binary Multiplication & Division

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

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

Data Representation. What is a number? Decimal Representation. Interpreting bits to give them meaning. Part 1: Numbers. six seis

4.3 TABLE 3 TABLE five

Background Information on Exponentials and Logarithms

Grade 6 Math Circles. Binary and Beyond

Basic numerical skills: FRACTIONS, DECIMALS, PROPORTIONS, RATIOS AND PERCENTAGES

Exponents and Radicals

Pemrograman Dasar. Basic Elements Of Java

Introduce Decimals with an Art Project Criteria Charts, Rubrics, Standards By Susan Ferdman

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

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

Data Storage. 1s and 0s

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

Cyber Security Workshop Encryption Reference Manual

Welcome to Basic Math Skills!

26 Integers: Multiplication, Division, and Order

First Bytes Programming Lab 2

Lesson Plan. Course Title: Computer Maintenance Session Title: Numbering Systems

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

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

Gates, Plexers, Decoders, Registers, Addition and Comparison

Introduction to Computer & Information Systems

Encoding Text with a Small Alphabet

The Subnet Training Guide

CS201: Architecture and Assembly Language

Japannext PTS ITCH Market Data Specification. Version 1.4 Updated 3 October 2014

Transcription:

Page 1 of 5 Unsigned Conversions from Decimal or to Decimal and other Number Systems In all digital design, analysis, troubleshooting, and repair you will be working with binary numbers (or base 2). It is sometimes necessary to convert from the binary number system to the decimal number system, because we are most familiar with and understand the decimal number system. After all, would you rather have someone give you $111101000 2 dollars or $500 dollars. There are several methods for converting between number systems, and you will have to decide which method to use. For those who are having a little trouble with this, I would learn how to convert from binary to decimal and from decimal to binary very well. Converting between binary, octal, and hexadecimal are not very difficult because octal and hexadecimal are really just short-hand versions of binary. So, let's start with converting between binary and decimal using unsigned numbers: Decimal Numbers: Although we are very familiar with the decimal system, there are some facts that are worth reviewing - as a starting point: The decimal (base 10) system has a total of 10 symbols representing the magnitude of a number. We know these symbols as the ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. We need to express numbers that are much larger than 9, and so different "placements" of digits represent different values. We know the number 539 means that we have 5 hundreds, 3 tens, and 9 ones. We don't normally think about it, but in essence we are saying that the magnitude of this number is: 5 * 10 2 + 3 * 10 1 + 9 * 10 0 = 500 + 30 + 9 = 539 What this means is that the magnitude (or value) of this number is: symbol(x) * base n + symbol(x-1) * base n-1 + symbol(x-2) * base n-2 + symbol(x-3) * base n-3 +... + symbol(0) * base 0 where: symbol is the digit we use to express the magnitude of a number in the current system base is the base of the current number system n is the exponent of the base representing that place-holder and x is the place-holder (we always star with the 1s place which is the base to the power of 0: X 0 =1, or any number raised to the power of 0 is equal to 1) We can use this method to convert from any other number system to decimal. Convert Binary to Decimal Using the method described above, you can convert from any number system to decimal. We need to know the base of the number system and the symbols used to represent digits. In converting binary to decimal, we know that the binary system uses a base of 2 and uses the symbols 0 and 1 (you cannot have more symbols than the base, and we always start with 0). In many texts you will see the word radix. Radix means the base of a number system (or logarithm). To convert from any other number system to decimal, use radix expansion (or base expansion) as shown below: Example: Convert Binary 110010111101 2 to Decimal Convert by means of radix expansion. That is, the relationship between the decimal value and the binary can be determined by the following relationship: Convert Octal to Decimal Using the method described above, you can convert from octal (base 8) to decimal. The symbols used for the octal number system are: 0, 1, 2, 3, 4, 5, 6, and 7. The base of the octal number system is 8. To convert from octal to decimal, we will again use the radix expansion method: Example: Convert Octal 7241 8 to Decimal Convert by means of radix expansion. decimal = 7 * 8 3 + 2 * 8 2 + 4 * 8 1 + 1 * 8 0 replacing the values for the base to the exponents we have,

Page 2 of 5 decimal = 7 * 512 + 2 * 64 + 4 * 8 + 1 * 1 decimal = 3584 + 128 + 32 + 1 = 3745 10 Convert Hexadecimal to Decimal One method to convert from hexadecimal (base 16) to decimal is radix expansion. The symbols used for the hexadecimal number system are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. We are not used to seeing symbols we generally use for words to be used for numbers, but it is better than creating completely new symbols. The base of the hexadecimal number system is 16. To convert from hexadecimal (or hex for short) to decimal, we will again use the radix expansion method: Example: Convert Hexadecimal A62E 16 to Decimal (sometimes you will see an "X" or an "h" used for a subscript to denote a hex number) Convert by means of radix expansion. decimal = A * 16 3 + 6 * 16 2 + 2 * 16 1 + E * 16 0 decimal = A * 4096 + 6 * 256 + 2 * 16 + E * 1 ten to their decimal equivalent replacing the values for the base to the exponents we have, now we need to replace those hex symbols for numbers larger than decimal = 10 * 4096 + 6 * 256 + 2 * 16 + 14 * 1 decimal = 40960 + 1536 + 32 + 14 = 42542 10 Converting from Decimal to Another Number System Converting from decimal to another number system requires a series of divisions. The algorithm to convert from decimal to another number system is: #1. Divide the decimal number by the radix (or base). The first pass through this algorithm, this will be the beginning or original number. For all other passes, this will be the whole number result of the division (the example below should make this statement clearer). #2. The remainder of the division becomes the next least significant digit (LSD) in the result. #3. Check to see if the whole number result of the division is 0. If it is, the algorithm is complete. If not, go back to step #1. Example: Convert Decimal 312 to binary.

Page 3 of 5 As the decimal number is divided by the radix, 2, the remainder is kept. Each remainder represents one digit of the final answer, starting at the least significant position. This same methodology can be used to convert from decimal to any other radix, for example octal and hexadecimal. Example: Convert Decimal 623 to Octal. So, the result is 1157 8 Example: Convert Decimal 44,094 to hexadecimal.

Page 4 of 5 So, the result is AC3E x Other Unsigned Conversions Because the octal and hexadecimal (and quartal - base 4, although that is not seen much these days) are just short-hand forms for binary, the conversions are not as complicated as they are for conversions between decimal and any other number system. To convert from binary to another system, group the binary digits (bits) into groups of log 2 (radix), and then replace the group of bits with its equivalent radix symbol. For example, to convert from binary to octal, group the bits into groups of 3 (log 2 (8) = 3), and then replace the bits with the octal digits. To convert from quartal, octal, or hexadecimal to binary, all you need to do is replace the digits with their equivalent group of binary digits. Convert Binary 110101111101 2 to Octal Combine the binary bits into groups of three from the binary point (far right for integers), then combine into octal characters. The equivalents table for octal to binary or binary to octal conversions are: 0 000 4 100 1 001 5 101 2 010 6 110 3 011 7 111 110 101 111 101 2 = 6 5 7 5 8 Convert Binary 110101111101 2 to Hexadecimal Combine the binary bits into groups of four from the binary point (far right for integers), then combine into hexadecimal characters. The equivalents table for hex to binary or binary to hex conversions are: 0 0000 4 0100 8 1000 C 1100 1 0001 5 0101 9 1001 D 1101 2 0010 6 0110 A 1010 E 1110 3 0011 7 0111 B 1011 F 1111 1101 0111 1101 2 = D 7 D 16 Convert Hexadecimal CBD 16 to Binary

Page 5 of 5 It is probably simplest to memorize the binary-hex equivalents and then just replace one for the other. The equivalents table for hex to binary or binary to hex conversions are: 0 0000 4 0100 8 1000 C 1100 1 0001 5 0101 9 1001 D 1101 2 0010 6 0110 A 1010 E 1110 3 0011 7 0111 B 1011 F 1111 Hex = C B D binary = 1100 1011 1101 binary = 110010111101 2 Convert Octal 6257 8 to Binary Using the same method above, replace the octal digits by their binary equivalents: The equivalents table for octal to binary or binary to octal conversions are: 0 000 4 100 1 001 5 101 2 010 6 110 3 011 7 111 Octal = 6 2 5 7 binary = 110 010 101 111 binary = 110010101111 2