CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 1 Number Systems.

Slides:



Advertisements
Similar presentations
DATA REPRESENTATION CONVERSION.
Advertisements

Chapter 2 : Number System
1 Number Systems Patt and Patel Ch A Brief History of Numbers From Gonick, Cartoon Guide to Computer Science.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Lecture 3 Number System.
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
CMPE12cGabriel Hugh Elkaim 1 Number Systems. CMPE12cGabriel Hugh Elkaim 2 A Brief History of Numbers From Gonick, Cartoon Guide to Computer Science.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Converting Binary to Octal
Number Systems and Arithmetic
BASICS OF COMPUTER APPLICATIONS ASB 102. UNIT 1 Introducing computer system  Number system  What is number system?  Types of number system  Their.
 Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal.
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
Numeral Systems Subjects: Numeral System Positional systems Decimal
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Numbering Systems CS208.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
The number systems of Computer Science
Chapter 3 Data Representation
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Date: Session III Topic: Number Systems Faculty: Anita Kanavalli Department of CSE M S Ramaiah.
Number systems, Operations, and Codes
Chapter1: Number Systems
Number Base Conversions
Positional Number Systems Decimal, Binary, Octal and Hexadecimal Numbers Wakerly Section
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
Number Systems. Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better,
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Chapter 2 Number Systems Consists of a set of symbols called digits and a set of relations such as +, -, x, /.
ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University.
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
Introduction To Number Systems Binary System M. AL-Towaileb1.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
CHAPTER 3: Number Systems
ECE 2110: Introduction to Digital Systems Number Systems: conversions.
ECE DIGITAL LOGIC LECTURE 2: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/14/2016.
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.
CPIT 201 King AbdulAziz University Faculty of Computing & Information Technology Information Technology Department CH 2 Number Systems CPIT 201 Introduction.
ECE 2110: Introduction to Digital Systems Number Systems: conversions.
Prepared By: Norakmar Binti Mohd Nadzari CHAPTER 2 ARITHMETIC AND LOGIC UNIT.
Introduction To Number Systems
Positional Number Systems Decimal, Binary, Octal and Hexadecimal Numbers Wakerly Section
Octal to Decimal Decimal Octal Binary Hexadecimal.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CHAPTER 1 : INTRODUCTION
ITE102 – Computer Programming (C++)
Number Systems Lab session 1 Xuan Guo.
Chapter 3 Data Representation
Number System conversions
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Chapter 1 Number Systems & Conversions
MMNSS COLLEGE,KOTTIYAM DEPARTMENT OF PHYSICS
1. Number Systems.
Numbering System TODAY AND TOMORROW 11th Edition
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Chapter 2: Number Systems
Digital Logic Design (CSNB163)
Chapter Four Data Representation in Computers By Bezawit E.
Numeral systems (radix)
Chapter 2 Number Systems.
Information Representation
1. Number Systems Chapt. 2.
Presentation transcript:

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 1 Number Systems

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 2 Number Systems Prehistory Unary, or marks: /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better, Arabic Numerals: = 12 = 1 x

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 3 Base 10 is a special case of positional number system PNS first used over 4000 years ago in Mesopotamia (Iraq) Base 60 (Sexagesimal) Digits: (written as 60 different symbols) 5,45 60 = 5 x x 1 = Positional number systems are great for arithmetic Why? Positional Number System

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 4 Arabic Numerals 345 is really –3 x x x 10 0 –3 x x x 1 –3 is the most significant symbol (carries the most weight) –5 is the least significant symbol (carries the least weight) Digits (or symbols) allowed: 0-9 Base (or radix): 10

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 5 Try multiplication in (non-positional) Roman numerals! XXXIII (33 in decimal) XII (12 in decimal) XXXIII CCCXXX CCCXXXXXXXXXIIIIII CCCLXXXXVI CCCXCVI = 396 in decimal Positional Number System The Mesopotamians wouldn’t have had this problem!! * +

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 6 There are many ways to “represent” a number Representation does not affect computation result LIX + XXXIII = LXXXXII (Roman) = 92 (Decimal) Representation affects difficulty of computing results Computers need a representation that works with fast electronic circuits Positional numbers work great with 2-state devices Positional Number System

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 7 Base (radix): 2 Digits (symbols) allowed: 0, 1 Binary Digits, or bits is really 1 x x X X is really 1 x x x x x Binary Number System

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 8 Computers multiply Arabic numerals by converting to binary, multiplying and converting back (much as us with Roman numerals) Binary Number System So if the computer is all binary how does it multiply 5 by 324 when I type it in the calculator program?

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 9 Octal Number System Base (radix): 8 Digits (symbols): 0 – is really –3 x x x 8 0 – – is really –1 x x x x 8 0 – – In C, octal numbers are represented with a leading 0 (0345 or 01001).

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 10 Hexadecimal Number System Base (radix): 16 Digits (symbols) allowed: 0 – 9, a – f HexDecimal a10 b11 c12 d13 e14 f15

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 11 A3 16 is really: A x x E8 16 is really: 3 x E x x x x x Hexadecimal Number System Some Examples of converting hex numbers to decimal

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 12 10C 16 is really: 1 x x C x x x In C, hex numbers are represented with a leading “0x” (for example “0xa3” or “0x10c”). Hexadecimal Number System

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 13 For any positional number system Base (radix): b Digits (symbols): 0 … b – 1 S n-1 S n-2 ….S 2 S 1 S 0 Use summation to transform any base to decimal Value = Σ (S i b i ) n-1 i=0 Positional Number System

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 14 Decimal -> Binary Conversion Divide decimal value by 2 until the value is 0 Know your powers of two and subtract … Example: 42 What is the biggest power of two that fits? What is the remainder? What fits? What is the remainder? What fits? What is the binary representation?

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 15 Binary -> Octal Conversion Group into 3’s starting at least significant symbol Add leading 0’s if needed (why not trailing?) Write 1 octal digit for each group Examples: (binary) (octal) (binary) (octal)

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 16 Octal -> Binary Conversion It is simple, just write down the 3-bit binary code for each octal digit OctalBinary

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 17 Binary -> Hex Conversion Group into 4’s starting at least significant symbol Adding leading 0’s if needed Write 1 hex digit for each group Examples: e f a 3

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 18 Hex -> Binary Conversion Again, simply write down the 4 bit binary code for each hex digit Example: 3 9 c

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 19 Conversion Table DecimalHexadecimalOctalBinary A B C D E F171111

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 20 Hex -> Octal Do it in 2 steps, hex -> binary -> octal Decimal -> Hex Do it in 2 steps, decimal -> binary -> hex So why use hex and octal and not just binary and decimal?

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 21 Negative Integers Most humans precede number with “-” (e.g., -2000) Accountants, however, use parentheses: (2000) or color 2000 Sign-magnitude format Example: in hex? = 3 x e x x E8 16

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 22 Mesopotamians used positional fractions Sqrt(2) = 1.24,51,10 60 = 1 x x x x = Most accurate approximation until the Renaissance

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 23 f n-1 f n-2 … f 2 f 1 f 0 f -1 f -2 f -3 … f m-1 Decimal point Generalized Representation For a number “f” with ‘n’ digits to the left and ‘m’ to the right of the decimal place Position is the power

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 24 Fractional Representation What is 3E.8F 16 ? How about ? = 3 x E x x F x = / /256 = 1 x x x x x 2 -3 = /2 + 1/8

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 25 Converting Decimal -> Binary fractions Consider left and right of the decimal point separately. The stuff to the left can be converted to binary as before. Use the following table/algorithm to convert the fraction

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 26 FractionFraction x 2Digit left of decimal point  most significant (f -1 ) (it must repeat from here!!) Different bases have different repeating fractions = … 2 = Numbers can repeat in one base and not in another. For to binary

CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 27 What is in: Binary Hex