Number System Decimal, Binary, OtlH Octal, Hex Conversion (one to another)

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

Binary Numbers. Binary Octal Hexadecimal

Lecture 11: 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

NUMBER SYSTEMS. 1.1 Introduction

Section 1.4 Place Value Systems of Numeration in Other Bases

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

Useful Number Systems

CSI 333 Lecture 1 Number Systems

3. Convert a number from one number system to another

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

Computer Science 281 Binary and Hexadecimal Review

CPEN Digital Logic Design Binary Systems

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

Decimal to Binary Conversion

Chapter 2. Binary Values and Number Systems

Lecture 8: Binary Multiplication & Division

Numbering Systems. InThisAppendix...

Positional Numbering System

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

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

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

Number and codes in digital systems

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

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

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

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

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

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

Base Conversion written by Cathy Saxton

6 The Hindu-Arabic System (800 BC)

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

Number Systems. Introduction / Number Systems

=

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Binary, Hexadecimal, Octal, and BCD Numbers

Lecture 2. Binary and Hexadecimal Numbers

Solution for Homework 2

Systems I: Computer Organization and Architecture

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

Binary Representation

Cyber Security Workshop Encryption Reference Manual

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

Number Systems and Radix Conversion

COMPSCI 210. Binary Fractions. Agenda & Reading

Accuplacer Arithmetic Study Guide

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

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

Number Representation

HOMEWORK # 2 SOLUTIO

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

Chapter 1: Digital Systems and Binary Numbers

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

Fractions to decimals

MEP Y9 Practice Book A

A Step towards an Easy Interconversion of Various Number Systems

NUMBER SYSTEMS. William Stallings

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

THE BINARY NUMBER SYSTEM

Verilog - Representation of Number Literals

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

Unsigned Conversions from Decimal or to Decimal and other Number Systems

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

CS201: Architecture and Assembly Language

CS321. Introduction to Numerical Methods

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

Chapter 5. Binary, octal and hexadecimal numbers

Paramedic Program Pre-Admission Mathematics Test Study Guide

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

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

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

Memory is implemented as an array of electronic switches

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

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

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

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

Seriously Simple Sums! Vedic Maths Free Tutorial. Maths Tips and Tricks to Improve Your Math Abilities

MATH-0910 Review Concepts (Haugen)

4.3 TABLE 3 TABLE five

1 Classical Universal Computer 3

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

Sequential Skills. Strands and Major Topics

BINARY CODED DECIMAL: B.C.D.

COMBINATIONAL CIRCUITS

Technical Support Bulletin Nr.18 Modbus Tips

Addition Methods. Methods Jottings Expanded Compact Examples = 15

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

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

Subnetting Study Guide

Pre-Algebra Lecture 6

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

The Hexadecimal Number System and Memory Addressing

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

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

TCP/IP Cheat Sheet. A Free Study Guide by Boson Software, LLC

Number of bits needed to address hosts 8

Chapter 1. Binary, octal and hexadecimal numbers

Computation Strategies for Basic Number Facts +, -, x,

AN617. Fixed Point Routines FIXED POINT ARITHMETIC INTRODUCTION. Thi d t t d ith F M k Design Consultant

Decimals and other fractions

Transcription:

Number system

Number System Outline Decimal, Binary, OtlH Octal, Hex Conversion (one to another) Decimal to Binary, Octal, Hex & Vice Versa Binary to HEX & vice versa Other representation Signed, Unsigned, Complement Operation Add, Sub, Mul, Div, Mod How to handle real number efficiently? Float, Double 2

What Digit? => Number System Famous Number System: Dec, Rom, Bin Decimal System: 0 9 May evolves: because human have 10 finger Roman System May evolves to make easy to look and feel Pre/Post Concept: (IV, V & VI) is (5 1, 5 & 5+1) Binary System, Others (Oct, Hex) One can cut an apple in to two 3

Significant Digits Binary: 11101101 Most significant digit Least significant digit Decimal: 1063079 Most significant digit Least significant digit

Decimal (base 10) Uses positional representation Each digit corresponds to a power of 10 based on its position in the number The powers of 10 increment from 0, 1, 2, etc. as you move right ihto lf left 1,479 = 1 * 10 3 + 4 * 10 2 + 7 * 10 1 + 9 * 10 0

Binary (base 2) Two digits: 0, 1 To make the binary numbers more readable, the digits are often put in groups of 4 1010 = 1 * 2 3 + 0 * 2 2 + 1 * 2 1 + 0 * 2 0 = 8 + 2 = 10 1100 1001 = 1 * 2 7 + 1 * 2 6 + 1 * 2 3 + 1 * 2 0 = 128 + 64 + 8 + 1 = 201

How to Encode Numbers: Binary Numbers Working with binary numbers In base ten, helps to know powers of 10 one, ten, hundred, thousand, ten thousand,... In base two, helps hl to know powers of 2 one, two, four, eight, sixteen, thirty two, sixty four, one hundred dtwenty t eight iht Count up by powers of two 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 a 512 256 128 64 32 16 8 4 2 1

Octal (base 8) Shorter & easier to read than binary 8 digits: 0, 1, 2, 3, 4, 5, 6, 7, Octal numbers 136 8 = 1 * 8 2 + 3 * 8 1 + 6 * 8 0 = 1 * 64 + 3 * 8 + 6 * 1 = 94 10

Hexadecimal (base 16) Shorter & easier to read than binary 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F 0x often precedes hexadecimal numbers 0x123 = 1 * 16 2 + 2 * 16 1 + 3 * 16 0 = 1 * 256 + 2 * 16 + 3 * 1 = 256 + 32 + 3 = 291

Decimal Binary Octal Hexadecimal Counting 0 00000 0 0 1 00001 1 1 2 00010 2 2 3 00011 3 3 4 00100 4 4 5 00101 5 5 6 00110 6 6 7 00111 7 7 8 01000 10 8 9 01001 11 9 10 01010 12 A 11 01011 13 B 12 01100 14 C 13 01101 15 D 14 01110 16 E 15 01111 17 F 16 10000 20 10 10

Fractional Number Point: Decimal Point, Binary Point, Hexadecimal point Decimal Binary 247.75 = 2x10 2 +4x10 1 +7x10 0 +7x10 1 +5x10 2 10.101= 1x2 1 +0x2 0 +1x2 1 +0x2 2 +1x2 3 Hexadecimal 6A.7D=6x16 1 +10x16 0 +7x16 1 +Dx16 2

Converting To and From Decimal Octal 8 0 1 2 3 4 5 6 7 Successive Division Weighted Multiplication Decimal 10 0 1 2 3 4 5 6 7 8 9 Successive Divisioni i Successive Division Weighted Multiplication li Binary 2 0 1 Weighted Multiplication li Hexadecimal 16 0 1 2 3 4 5 6 7 8 9 A B C D E F 12

Decimal Binary Successive Division a) Divide the decimal number by 2; ; the remainder is the LSB of the binary number. b) If the quotation is zero, the conversion is complete. Otherwise repeat step (a) () using the quotation as the decimal number. The new remainder is the next most significant bit of the binary number. Weighted Multiplication a) Multiply each bit of the binary number by its corresponding bitweighting factor (i.e., Bit 0 2 0 =1; Bit 1 2 1 =2; Bit 2 2 2 =4; etc). b) Sum up all of the products in step (a) to get the decimal number.

Decimal to Binary : Subtraction Method Goal Desired decimal number: 12 Good for human Get the binary weights to add up to the decimal quantity Work from left to right (Right to left may fill in 1s that shouldn t have been there try it). 32 16 8 4 1 =32 2 32 16 8 4 2 1 too much 0 1 =16 32 32 16 16 8 8 4 4 2 2 1 1 1 too much 0 0 1 =8 32 16 8 4 2 1 ok, keep going 0 0 1 1 =8+4=12 DONE a 0 0 1 1 0 0 answer 32 16 8 4 2 1

Decimal to Binary : Division Method Good for computer: Divide decimal number by 2 and insert remainder into new binary number. Continue dividing quotient by 2 until the quotient is 0. Example: Convert decimal number 12 to binary 12 div 2 = ( Quo=6, Rem=0) LSB 6 div 2 = (Quo=3, Rem=0) 3 div 2 = (Quo=1,Rem=1) 1 div 2 = ( Quo=0, Rem=1) MSB 12 10 = 1 1 00 2

Conversion Process Decimal Base N Successive Division a) Divide the decimal number by N; ; the remainder is the LSB of the ANY BASE Number. b) If the quotient is zero, the conversion is complete. Otherwise repeat step (a) () using the quotient as the decimal number. The new remainder is the next most significant bit of the ANY BASE number. Weighted Multiplication a) Multiply each bit of the ANY BASE number by its corresponding bitweighting factor (i.e., Bit 0 N 0 ; Bit 1 N 1 ; Bit 2 N 2 ; etc). b) Sum up all of the products in step (a) to get the decimal number.

Decimal Octal Conversion The Process: Successive Division Divide number by 8; R is the LSB of the octal number While Q is 0 Using the Q as the decimal number. New remainder is MSB of the octal number. 11 8 94 r = 6 LSB 1 8 11 r = 3 94 10 = 136 8 0 8 1 r 1 MSB = 17

Decimal Hexadecimal Conversion The Process: Successive Division Divide number by 16; R is the LSB of the hex number While Q is 0 Using the Q as the decimal number. New remainder is MSB of the hex number. 5 16 94 r = E LSB 0 16 5 r = 5 MSB 94 10 = 5E 16

Example: Hex Octal Example: Convert the hexadecimal number 5A H into its octal equivalent. Solution: First convert the hexadecimal number into its decimal equivalent, then convert the decimal number into its octal equivalent. 11 5 A 8 90 r = 2 LSB 16 1 16 0 16 1 8 1 11 r = 3 80 + 10 = 90 10 8 1 r = 1 MSB 0 5A H = 132 8 19

Example: Octal Binary Example: Convertthe the octal number 132 8 into its binary equivalent. Solution: First convert the octal number into its decimal equivalent, then convert the decimal number into its binary equivalent. 1 3 2 8 2 8 1 8 0 64 8 1 64 + 24 + 2 = 90 10 1 2 45 90 r = 0 LSB 22 2 45 r = 1 11 2 22 r = 0 5 2 11 r = 1 2 2 5 r = 1 1 2 2 r = 0 0 2 1 r = 1 MSB 132 8 = 1011010 2 20

Binary Octal Hex Shortcut Relation Binary, octal, and hex number systems All powers of two Exploit (This Relation) Make conversion easier. 21

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

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

Other Representation Signed & Unsigned Number Signed number last bit (one MSB) is signed dbit Assume: 8 bit number Unsigned 12 : 0000 1100 Signed +12 : 0000 1100 Signed 12 : 1000 1100 Complement number Unsigned binary 12 = 00001100 1 s 1s Complement of 12 = 1111 0011 24

Thanks 25