Conversions between Decimal and Binary

Similar documents
MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

ECE380 Digital Logic. Positional representation

ENGIN 112 Intro to Electrical and Computer Engineering

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

CSE 241 Digital Systems Spring 2013

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

Menu. Review of Number Systems EEL3701 EEL3701. Math. Review of number systems >Binary math >Signed number systems

Four Important Number Systems

CISC 1400 Discrete Structures

Number Theory: Representations of Integers

CHAPTER 2 NUMBER SYSTEMS

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

Number Bases. Ioan Despi. University of New England. August 4, 2013

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

0,..., r 1 = digits in radix r number system, that is 0 d i r 1 where m i n 1

NUMBERS AND CODES CHAPTER Numbers

2.5 정수와알고리즘 (Integers and Algorithms)

Base-b representations of integers. (b 진법표현 ) Algorithms for computer arithmetic: Euclidean algorithm for finding GCD s.

ENGIN 112 Intro to Electrical and Computer Engineering

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

Hakim Weatherspoon CS 3410 Computer Science Cornell University

CSE 20: Discrete Mathematics

Chapter 1 CSCI

12/31/2010. Digital Operations and Computations Course Notes. 01-Number Systems Text: Unit 1. Overview. What is a Digital System?

hexadecimal-to-decimal conversion

Week No. 06: Numbering Systems

Number Representations

Counting in Different Number Systems

Numbers and Arithmetic

Digital Systems Overview. Unit 1 Numbering Systems. Why Digital Systems? Levels of Design Abstraction. Dissecting Decimal Numbers

Binary addition example worked out

CSE 20 DISCRETE MATH. Fall

Design of Digital Circuits Reading: Binary Numbers. Required Reading for Week February 2017 Spring 2017

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation

Fundamentals of Digital Design

ECE260: Fundamentals of Computer Engineering

Discrete Mathematics GCD, LCM, RSA Algorithm

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary

CSEN102 Introduction to Computer Science

ECE 372 Microcontroller Design

Part I, Number Systems. CS131 Mathematics for Computer Scientists II Note 1 INTEGERS

Introduction CSE 541

Complement Arithmetic

Lecture 2 Review on Digital Logic (Part 1)

Numbers. Dr Hammadi Nait-Charif. Senior Lecturer Bournemouth University United Kingdom

Numbers and Arithmetic

convert a two s complement number back into a recognizable magnitude.

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

CSCI 255. S i g n e d N u m s / S h i f t i n g / A r i t h m e t i c O p s.

0 / 1 Now, Binary value of the given number :-

1 Computing System 2. 2 Data Representation Number Systems 22

We say that the base of the decimal number system is ten, represented by the symbol

CPE100: Digital Logic Design I

Resource: color-coded sets of standards cards (one page for each set)

3 The fundamentals: Algorithms, the integers, and matrices

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

CS1800 Discrete Structures Fall 2017 October, CS1800 Discrete Structures Midterm Version A

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

Computer Number Systems

CHAPTER 7. Exercises 17/ / /2 2 0

ALU (3) - Division Algorithms

Standard forms for writing numbers

EDULABZ INTERNATIONAL NUMBER SYSTEM

Computer Arithmetic. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Computer Arithmetic

4 Number Theory and Cryptography

Cs302 Quiz for MID TERM Exam Solved

Combinational Logic. By : Ali Mustafa

Computer Architecture 10. Residue Number Systems

Why digital? Overview. Number Systems. Binary to Decimal conversion

Midterm Examination # 1 Wednesday, February 25, Duration of examination: 75 minutes

Chapter 9 - Number Systems

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 2 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Informatics 1 - Computation & Logic: Tutorial 3

K K.OA.2 1.OA.2 2.OA.1 3.OA.3 4.OA.3 5.NF.2 6.NS.1 7.NS.3 8.EE.8c

Chapter 5. Number Theory. 5.1 Base b representations

Playing with Numbers. introduction. numbers in general FOrM. remarks (i) The number ab does not mean a b. (ii) The number abc does not mean a b c.

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C.

Numbers. 2.1 Integers. P(n) = n(n 4 5n 2 + 4) = n(n 2 1)(n 2 4) = (n 2)(n 1)n(n + 1)(n + 2); 120 =

ENG2410 Digital Design Introduction to Digital Systems. Fall 2017 S. Areibi School of Engineering University of Guelph

REVIEW Chapter 1 The Real Number System

Binary Arithmetic: counting with ones

Math 230 Assembly Language Programming (Computer Organization) Numeric Data Lecture 2

Part 5: Digital Circuits

Computer Architecture, IFE CS and T&CS, 4 th sem. Representation of Integer Numbers in Computer Systems

Chapter 1. Binary Systems 1-1. Outline. ! Introductions. ! Number Base Conversions. ! Binary Arithmetic. ! Binary Codes. ! Binary Elements 1-2

L1 2.1 Long Division of Polynomials and The Remainder Theorem Lesson MHF4U Jensen

Number System conversions

Quantitative Aptitude

Next, we include the several conversion from type to type.

Finite Fields. SOLUTIONS Network Coding - Prof. Frank H.P. Fitzek

CSE 20 DISCRETE MATH. Winter

Graduate Institute of Electronics Engineering, NTU Basic Division Scheme

UNIVERSITI TENAGA NASIONAL. College of Information Technology

L1 2.1 Long Division of Polynomials and The Remainder Theorem Lesson MHF4U Jensen

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

N= {1,2,3,4,5,6,7,8,9,10,11,...}

of Digital Electronics

4. Number Theory (Part 2)

Ch 7 Summary - POLYNOMIAL FUNCTIONS

Transcription:

Conversions between Decimal and Binary Binary to Decimal Technique - use the definition of a number in a positional number system with base 2 - evaluate the definition formula ( the formula ) using decimal arithmetic Example 543210 position = corresponding power of 2 101011 = 1 2 5 + 0 2 4 + 1 2 3 + 0 2 2 + 1 2 1 + 1 2 0 = 43 (decimal) d 5 d 4 d 3 d 2 d 1 d 0 generalize: Octal to Decimal, Hexadecimal to Decimal, any base to Decimal EECS 1520 Week 3.2 September 21, 2017 page 1

Decimal to Binary Technique - repeatedly divide by 2 - remainder is the next digit - binary number is developed right to left Example 173 2 86 1 1 86 2 43 0 01 43 2 21 1 101 21 2 10 1 1101 10 2 5 0 01101 5 2 2 1 101101 2 2 1 0 0101101 1 2 0 1 10101101 generalize: Decimal to Octal, Decimal to Hexadecimal, Decimal to any base EECS 1520 Week 3.2 September 21, 2017 page 2

What is going on in the repeated division by 2? Example 43 2 21 1 1 21 2 10 1 11 10 2 5 0 011 5 2 2 1 1011 2 2 1 0 01011 1 2 0 1 101011 43 (decimal) = 1 2 5 + 0 2 4 + 1 2 3 + 0 2 2 + 1 2 1 + 1 2 0 43 2 produces a quotient of 21, with a remainder of 1 43 2 = 1 2 4 + 0 2 3 + 1 2 2 + 0 2 1 + 1 2 0 + 1 2-1 21 (decimal) = 1 2 4 + 0 2 3 + 1 2 2 + 0 2 1 + 1 2 0 21 2 produces a quotient of 10, with a remainder of 1 21 2 = 1 2 3 + 0 2 2 + 1 2 1 + 0 2 0 + 1 2-1 EECS 1520 Week 3.2 September 21, 2017 page 3

10 (decimal) = 1 2 3 + 0 2 2 + 1 2 1 + 0 2 0 10 2 produces a quotient of 5, with a remainder of 0 10 2 = 1 2 2 + 0 2 1 + 1 2 0 + 0 2-1 5 (decimal) = 1 2 2 + 0 2 1 + 1 2 0 5 2 produces a quotient of 2, with a remainder of 1 5 2 = 1 2 1 + 0 2 0 + 1 2-1 2 (decimal) = 1 2 1 + 0 2 0 2 2 produces a quotient of 1, with a remainder of 0 2 2 = 1 2 0 + 0 2-1 1 (decimal) = 1 2 0 1 2 produces a quotient of 0, with a remainder of 1 1 2 = 1 2-1 EECS 1520 Week 3.2 September 21, 2017 page 4

Generalization: Conversions between Decimal and base b base b to Decimal Technique - use the definition of a number in a positional number system with base b - evaluate the definition formula ( the formula ) using decimal arithmetic Decimal to base b Technique - repeatedly divide by b - remainder is the next digit - base b number is developed right to left EECS 1520 Week 3.2 September 21, 2017 page 5

Conversions between Binary and Octal or Hexadecimal Binary to Octal Technique - group bits into threes, right to left - convert each such group to an octal digit Example 1011010111 = 1 011 010 111 = 1327 (octal) Binary to Hexadecimal Technique - group bits into fours, right to left - convert each such group to a hexadecimal digit Example 1011001011 = 10 1100 1011 = 2CB (hexadecimal) EECS 1520 Week 3.2 September 21, 2017 page 6

Octal to Binary Technique - convert each octal digit to a three-bit binary representation Example 705 = 111 000 101 = 111000101 (binary) Hexadecimal to Binary Technique - convert each octal digit to a four-bit binary representation Example 10AF = 0001 0000 1010 1111 = 1000010101111 (binary) EECS 1520 Week 3.2 September 21, 2017 page 7

You will need the following tables in the above conversion process: (These can easily be constructed in the margins of a test paper when needed, or digit by digit on the fly ) Binary Octal Binary Hexadecimal Octal Binary Hex Binary digit digit 0 000 0 0000 8 1000 1 001 1 0001 9 1001 2 010 2 0010 (10) A 1010 3 011 3 0011 (11) B 1011 4 100 4 0100 (12) C 1100 5 101 5 0101 (13) D 1101 6 110 6 0110 (14) E 1110 7 111 7 0111 (15) F 1111 EECS 1520 Week 3.2 September 21, 2017 page 8

What about converting between Octal and Hexadecimal? Octal to Hexadecimal: Convert Octal to Binary and then convert Binary to Hexadecimal. Hexadecimal to Octal: Convert Hexadecimal to Binary, and then convert Binary to Octal. EECS 1520 Week 3.2 September 21, 2017 page 9

Representing Natural Numbers with a finite number of digits General property Number of digits Min Max nn 0 bb nn 1 Examples: b=10, n=3 000 to 999 b=2, n=3 000 to 111 (equivalent to 0 to 7, in decimal) b=8, n=3 000 to 777 (equivalent to 0 to 511, in decimal) b=16, n=3 000 to FFF (equivalent to 0 to, in decimal) EECS 1520 Week 3.2 September 21, 2017 page 10

Integers Basic definition an integer is a number which has no fractional part Examples: +123-67 Representation of Integers previously: unsigned numbers only, i.e. the natural numbers need notation to represent both positive and negative numbers two schemes: 1) sign-magnitude, 2) complementary representation Sign-Magnitude in binary: sign: left-most bit (0 = positive, 1 = negative) magnitude: remaining bits Example: (using 6-bit sign-magnitude representation) +5 = 000101-5 = 100101 EECS 1520 Week 3.2 September 21, 2017 page 11

Ranges (for Binary numbers) Unsigned (Natural Numbers) Sign-Magnitude (Integers) Number of bits Min Max Min Max 1 0 1 2 0 3-1 +1 3 0 7-3 +3 4 0 15-7 +7 5 0 31-15 +15 6 0 63-31 +31 etc. nn 0 2 nn 1 (2 nn 1 1) +(2 nn 1 1) EECS 1520 Week 3.2 September 21, 2017 page 12

Difficulties with Sign-Magnitude two representations for zero +0 = 000000-0 = 100000 (6-bit binary example) arithmetic is awkward, especially subtraction Complementary Representation positive numbers are represented by their corresponding natural numbers negative numbers are represented by (very) large natural numbers subtraction reduces to addition (of the representative natural numbers) note: complementary representation requires a fixed size (number of digits) representatives of the natural numbers: xx bb nn xx EECS 1520 Week 3.2 September 21, 2017 page 13

Example: (of Ten s Complement) Let b = 10 and n = 2 Positive Negative Numbers Numbers 00 (+0) 01 (+1) 99 (-1) 02 (+2) 98 (-2) 03 (+3) 97 (-3) 49 (+49) 51 (-49) 50 (-50) EECS 1520 Week 3.2 September 21, 2017 page 14

Visualization EECS 1520 Week 3.2 September 21, 2017 page 15

Examples of Arithmetic in Ten s Complement Add: -35 plus +25 equals -10 65 plus 25 equals 90 Add: +17 plus +25 equals +42 17 plus 25 equals 42 Add: +20 plus -30 equals -10 20 plus 70 equals 90 Add: -20 plus +30 equals +10 80 plus 30 equals 10 (110) subtraction reduces to addition because A B = A + (-B) easy to convert (the representative) a positive number to its negative counterpart, and to convert (the representative) of a negative number to its positive counterpart 80 represents -20, 100 80 = 20, which represents +20 20 represents +20, 100 20 = 80, which represents -20 EECS 1520 Week 3.2 September 21, 2017 page 16