Number Systems - Part II

Slides:



Advertisements
Similar presentations
ECE 331 – Digital System Design
Advertisements

DATA REPRESENTATION CONVERSION.
Lecture - 2 Number systems and computer data formats
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Lecture 3 Number System.
Number Systems. 2 The total number of allowable symbols in a number system is called the radix or base of the system. Decimal Numbers: radix = 10 (symbols:
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
ECE 301 – Digital Electronics Course Introduction, Number Systems, Conversion between Bases, and Basic Binary Arithmetic (Lecture #1)
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
BASICS OF COMPUTER APPLICATIONS ASB 102. UNIT 1 Introducing computer system  Number system  What is number system?  Types of number system  Their.
Chapter 1 1 Number Systems. 2 Objectives  Understand why computers use binary (Base-2) numbering.  Understand how to convert Base-2 numbers to Base-
Number Systems Lecture 02.
Binary Number Systems.
Binary Representation and Computer Arithmetic
Number Systems - Part I CS 215 Lecture # 5.
Dr. Bernard Chen Ph.D. University of Central Arkansas
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of numbers
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
MATH 224 – Discrete Mathematics
Data Representation – Binary Numbers
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
Chapter 3 Data Representation
Data Representation - Part I. Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen.
Binary Fractions. Fractions A radix separates the integer part from the fraction part of a number Columns to the right of the radix have negative.
Integer Conversion Between Decimal and Binary Bases Conversion of decimal to binary more complicated Task accomplished by –Repeated division of decimal.
Number Systems and Codes. CS2100 Number Systems and Codes 2 NUMBER SYSTEMS & CODES Information Representations Number Systems Base Conversion Negative.
Integer Representation for People Computer Organization and Assembly Language: Module 3.
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Number systems, Operations, and Codes
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
CMSC 104, Lecture 051 Binary / Hex Binary and Hex The number systems of Computer Science.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Data Representation, Number Systems and Base Conversions
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Introduction To Number Systems Binary System M. AL-Towaileb1.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Numbers in Computers.
Lecture 6: Floating Point Number Representation Information Representation: Floating Point Number Representation Lecture # 7.
CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
Prepared By: Norakmar Binti Mohd Nadzari CHAPTER 2 ARITHMETIC AND LOGIC UNIT.
CPE 201 Digital Design Lecture 2: Digital Systems & Binary Numbers (2)
William Stallings Computer Organization and Architecture 8th Edition
CS2100 Computer Organisation
Fundamentals of Computer Science
Introduction To Number Systems
CS2100 Computer Organisation
Introduction To Computer Science
Chapter 3 Data Representation
Number System conversions
CS1010 Programming Methodology
Data Structures Mohammed Thajeel To the second year students
Data Representation Data Types Complements Fixed Point Representation
ECEG-3202 Computer Architecture and Organization
Numbering Systems and Arithmetic operations on Hex, binary, and octal
Digital Logic Design (CSNB163)
ECE 301 – Digital Electronics
COMS 161 Introduction to Computing
Number Systems.
Presentation transcript:

Number Systems - Part II CS 215 Lecture # 6

Conversion from Decimal Let N be the number to be converted. We can write N as N = q*b + r where q = quotient b = the base into which N is to be converted r = remainder

Example 6.1 Convert 8010 to binary (base 2) 80 = 40*2 + 0 40 = 20*2 + 0 20 = 10*2 + 0 10 = 5*2 + 0 5 = 2*2 + 1 2 = 1*2 + 0 1 = 0*2 + 1 Answer: 10100002

Example 6.2 Convert 8010 to octal(base 8) 80 = 10*8 + 0 10 = 1*8 + 2 10 = 1*8 + 2 1 = 0*8 + 1 Answer: 8010 = 1208 Also, from binary: 8010 = 10100002 = 1 010 000 = 120

Example 6.3 Convert 8010 to hexadecimal(base 16) 80 = 5*16 + 0 5 = 0*16 + 5 Answer: 8010 = 5016 Also, from binary: 8010 = 10100002 = 101 0000 = 50

Conversion from Decimal Decimal  Binary or Hexadecimal Repeated division by 2 or 16 Example: Convert 292 to hexadecimal. 292/16 = 18 R 4 18/16 = 1 R 2 1/16 = 0 R 1 292 = 12416 When the quotient is less than 16, the process ends

Conversion from Decimal Convert 42 to hexadecimal 42/16 = 2 R 10 (but 10 = a16) 2/16 = 0 R 2 42 = 2a16 Convert 109 to binary 109/2 = 54 R 1 54/2 = 27 R 0 27/2 = 13 R 1 13/2 = 6 R 1 6/2 = 3 R 0 3/2 = 1 R 1 1/2 = 0 R 1 109 = 11011012

Shortcut: convert to hexadecimal It is sometimes easier to convert from binary to hexadecimal, then to decimal, instead of converting directly to decimal 11101010110110 = 0011 1010 1011 0110 = 3 a b 6 = 3*16^3 + 10*16^2 + 11*16 + 6 = 3*4096 + 10*256 + 176 + 6 = 12198 + 2560 + 182 = 12198 + 2742 = 14940

Shortcut: convert to hexadecimal The converse is also true: converting from decimal to hexadecimal, then to binary generally requires far fewer steps than converting directly to binary 278/16 = 17 R 6 17/16 = 1 R 1 1/16 = 0 R 1 278 = 11616 = 0001 0001 01102 = 1000101102

Example 6.4 Convert the following: 5010 = ____16 5010 = ____8 5010 = ____2 5010 = ____5

Conversion of Fractions A decimal improper fraction a/b is converted into a different base b by converting it into a mixed fraction a/b = d e/f e.g. 13/8 = 1 5/8 convert d into the required base using the techniques we have already discussed convert e/f (now a proper fraction) into the required base by following the steps below the answer is in the format ...f1f0.f-1f-2...

Example 6.5 Convert 2 5/8 to binary 2*(5/8) = 1 + 1/4 2*(1/4) = 0 + 1/2 2*(1/2) = 1 + 0 Answer: 10.101

Example 6.6 Convert 3.6 to binary 2*.6 = 1 + .2 2*.2 = 0 + .4 2*.4 = 0 + .8 2*.8 = 1 + .6 Answer: 11.10011001...

Converting back into decimal 10.101 fraction part = 1*(1/2)1 + 0*(1/2)2 + 1*(1/2)3 = .625 or 5/8 integer part = 1*(21) + 0*(20) = 2 Answer: 2 5/8

Scientific Notation Given a number N, we can express N as N = s*rx where s = mantissa or significand r = radix x = exponent

The mantissa can be made an integer by multiplying it with a fixed power of the radix and subtracting the appropriate integer constant from the exponent For example, 2.358 * 101 = 2358 * 10-2

Normalization Standard scientific notation defines the normal form to meet the following rule. 1 £ s < r where s = significand r = radix A representation is in normal form if the radix point occurs just to the right of the first significant symbol

Example 6.7 2358 * 10-2 = 2.358 * 101 1525 * 10-1 = 1.525 * 102

Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen representation must allow for efficient execution of primitive operations For general-purpose computers, the representation must allow efficient algorithms for addition of two integers determination of additive inverse

Representing Numbers With a sequence of N bits, there are 2N unique representations Each memory cell can hold N bits The size of the memory cell determines the number of unique values that can be represented The cost of performing operations also increases as the size of the memory cell increases It is reasonable to select a memory cell size such that numbers that are frequently used are represented

Binary Representation The binary, weighted positional notation is the natural way to represent non-negative numbers. MAL numbers the bits from right to left, beginning with 0 as the least significant digit. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Modulo Arithmetic Consider the set of number {0, … ,7} Suppose all arithmetic operations were finished by taking the result modulo 8 3 + 6 = 9, 9 mod 8 = 1 3 + 6 = 1 3*5 = 15, 15 mod 8 = 7 3 * 5 = 7 1 2 3 4 5 6 7

Modulo Arithmetic: Additive Inverse What is the additive inverse of 7? 7 + x = 0 7 + 1 = 0 0 and 4 are their own additive inverses 1 2 3 4 5 6 7