Beyond Base 10: Non-decimal Based Number Systems

Similar documents
Beyond Base 10: Non-decimal Based Number Systems

Number representations

Digital Fundamentals

MACHINE LEVEL REPRESENTATION OF DATA

CHW 261: Logic Design

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Objectives. Connecting with Computer Science 2

The type of all data used in a C++ program must be specified

BINARY SYSTEM. Binary system is used in digital systems because it is:

Chapter 2. Data Representation in Computer Systems

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

The. Binary. Number System

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System

Review of Number Systems

umber Systems bit nibble byte word binary decimal

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Final Labs and Tutors

CS & IT Conversions. Magnitude 10,000 1,

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

in this web service Cambridge University Press

Electronic Data and Instructions

CMPS 10 Introduction to Computer Science Lecture Notes

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Digital Computers and Machine Representation of Data

Number Systems Base r

COMP Overview of Tutorial #2

Number codes nibble byte word double word

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Chapter 1 Preliminaries

Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Level ISA3: Information Representation

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Binary Representation. Jerry Cain CS 106AJ October 29, 2018 slides courtesy of Eric Roberts

Introduction to Numbering Systems

Inf2C - Computer Systems Lecture 2 Data Representation

NUMERIC SYSTEMS USED IN NETWORKING

Digital Fundamentals

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Chapter 3 DATA REPRESENTATION

A. Incorrect! To simplify this expression you need to find the product of 7 and 4, not the sum.

The type of all data used in a C (or C++) program must be specified

Chapter 2 Bits, Data Types, and Operations

Introduction to Computers and Programming. Numeric Values

Octal & Hexadecimal Number Systems. Digital Electronics

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Introduction to Informatics

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Data Representation 1

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

COMP2121: Microprocessors and Interfacing. Number Systems

CHAPTER 2 Number Systems

Module 3: Representing Values in a Computer

Number Systems and Number Representation

Number Systems CHAPTER Positional Number Systems

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

Bits. Binary Digits. 0 or 1

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Number Systems. Dr. Tarek A. Tutunji Philadelphia University, Jordan

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

TOPICS. Other Number Systems. Other Number Systems 9/9/2017. Octal Hexadecimal Number conversion

Chapter 2 Binary Values and Number Systems

DATA REPRESENTATION. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift, Jaipur Region. Based on CBSE curriculum Class 11. Neha Tyagi, KV 5 Jaipur II Shift

Programming Concepts and Skills. ASCII and other codes

Chapter 2 Bits, Data Types, and Operations

Fundamentals of Programming (C)

Lecture 2: Number Systems

CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems

Appendix 2 Number Representations

Intermediate Programming & Design (C++) Notation

Conversion Between Number Bases

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

Number Systems. Both numbers are positive

Chapter 1 Review of Number Systems

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2.

Computer Science 1000: Part #3. Binary Numbers

Decimal/Binary Conversion on the Soroban

Chapter 2 Bits, Data Types, and Operations

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

MC1601 Computer Organization

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

D I G I T A L C I R C U I T S E E

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

Fundamentals of Programming Session 2

Integers and Rational Numbers

Internal Data Representation

Bits, Words, and Integers

Transcription:

Beyond Base : Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and hex) How to convert to and from nondecimal number systems to decimal Binary math What Is Decimal? Base unique symbols are used to represent values 3 4 5 6 7 8 9 : The number of digits is based on the number of digits The largest decimal value that can be represented by a single decimal digit is 9 = base() -

Binary Base two Employs two unique symbols ( and ) Largest decimal value that can be represented by binary digit = = base() - Table Of Binary Values Decimal value Binary value Decimal value Binary value 8 9 3 4 5 3 6 4 7 5

Why Bother With Binary? Representing information ASCII (American Standard Code for Information Interchange) Unicode It's the language of the computer Representing Information: ASCII Decimal 3 3 47 48-57 58 64 65-9 9 96 97 3 7 Binary - ASCII Invisible (control characters) Punctuation, mathematical operations Characters - 9 Comparators and other miscellaneous characters : ;? @ Alphabetic (upper case A - Z) More miscellaneous characters [ \ ] ^ _ ' Alphabetic (lower case a - z) More miscellaneous characters { } ~ DEL

Representing Information: ASCII () Uses 7 bits to represent characters Max number of possibilities = 7 = 8 characters that can be represented e.g., 'A' is 65 in decimal or in binary. In memory it looks like this: Representing Information: Unicode Uses 6 bits (or more) to represent information Max number of possibilities = 6 = 65536 characters that can be represented (more if more bits are used)

Computer Programs Binary is the language of the computer ) A programmer writes a computer program ) The compiler translates the program into a form that the computer can understand 3) An executable program is created 4) Anybody who has this executable installed on their computer can then run (use) it. Octal Base eight Employs eight unique symbols ( - 7) Largest decimal value that can be represented by octal digit = 7 = base(8) -

Table Of Octal Values Decimal value Octal value Decimal value Octal value 8 9 3 3 3 4 4 4 5 5 3 5 6 6 4 6 7 7 5 7 Why Octal????

Why Octal? () Machine language Octal value 7 5 Hexadecimal (Hex) Base sixteen Employs sixteen unique symbols ( 9, followed by A - F) Largest decimal value that can be represented by hex digit = 5

Table of Hex Values Decimal value Hexadecimal value Decimal value Hexadecimal value 9 9 A B 3 3 C 4 4 3 D 5 5 4 E 6 6 5 F 7 7 6 8 8 7 Why Hexadecimal?? Or?

Why Hexadecimal? () Machine Hexadecimal language value 4C 6E Example from 68 Family Assembly Language by Clements A. Summary (Decimal, Binary, Octal, Hex) Decimal Binary Octal Hex Decimal Binary Octal Hex 8 8 9 9 A 3 3 3 3 B 4 4 4 4 C 5 5 5 3 5 D 6 6 6 4 6 E 7 7 7 5 7 F

High Vs. Low Level Human languages High level programming language E.g., English, French, Spanish, Chinese, German etc. E.g., Pascal, Java, C++ High level Low level programming language Assembly Machine language Binary Computer hardware Low level Overflow: A Real World Example You can only represent a finite number of values

Overflow: Binary Occurs when you don't have enough bits to represent a value ( wraps around to zero) Binary ( bit) Value Binary ( bits) Value 3 : : 3 : : Binary (3 bits) Value 3 4 5 6 7 : : Arbitrary Number Bases Base N Employs N unique symbols Largest decimal value that can be represented by digit = Base (N) -

Converting Between Different Number Systems Binary to/from octal Binary to/from hexadecimal Octal to/from hexadecimal Decimal to any base Any base to decimal Binary To Octal 3 binary digits equals one octal digit (remember 3 =8) Form groups of three starting at the decimal For the integer portion start grouping at the decimal and go left For the fractional portion start grouping at the decimal and go right e.g. =??? 8 5 4 8.

Octal To Binary octal digit equals = 3 binary digits Split into groups of three starting at the decimal For the integer portion start splitting at the decimal and go left For the fractional portion start splitting at the decimal and go right e.g..5 8 =???. Binary To Hexadecimal 4 binary digits equals one hexadecimal digit (remember 4 =6) Form groups of four at the decimal For the integer portion start grouping at the decimal and go left For the fractional portion start grouping at the decimal and go right e.g.,. =??? 6 8. 4 6

Hexadecimal To Binary hex digit equals = 4 binary digits Split into groups of four starting at the decimal For the integer portion start splitting at the decimal and go left For the fractional portion start splitting at the decimal and go right e.g., A.3 6 =???. Octal To Hexadecimal Convert to binary first! e.g., 5 8 to??? 6.

Octal To Hexadecimal Convert to binary first! e.g., 5 8 to??? 6 Add any leading zeros that are needed (in this case two). Regroup in groups of 4. 5 6. Hexadecimal To Octal e.g., 5 6 to??? 8.

Hexadecimal To Octal e.g., 5 6 to??? 8. Add any leading zeros that are needed (in this case one). Regroup in groups of 3 5 8. Decimal To Any Base Split up the integer and the fractional portions ) For the integer portion: a. Divide the integer portion of the decimal number by the target base. b. The remainder becomes the first integer digit of the number (immediately left of the decimal) in the target base. c. The quotient becomes the new integer value. d. Divide the new integer value by the target base. e. The new remainder becomes the second integer digit of the converted number (second digit to the left of the decimal). f. Continue dividing until the quotient is less than the target base and this quotient becomes the last integer digit of the converted number.

Decimal To Any Base () ) For the fractional portion: a. Multiply by the target base. b. The integer portion (if any) of the product becomes the first rational digit of the converted number (first digit to the right of the decimal). c. The non-rational portion of the product is then multiplied by the target base. d. The integer portion (if any) of the new product becomes the second rational digit of the converted number (second digit to the right of the decimal). e. Keep multiplying by the target base until either the resulting product equals zero or you have the desired number of places of precision. Decimal To Any Base () e.g., 9 to???. 9 / : q = 4 r = 4/ : q = r = /: q = r = Stop dividing! (quotient less than target base)

Any Base To Decimal Multiply each digit by the base raised to some exponent and sum the resulting products. i.e. d7 d6 d5 d4. d3 d d b Base = b 3 - - -3 Position of digits Number to be converted Value in decimal = (digit7*b 3 ) + (digit6*b ) + (digit5*b ) + (digit4*b ) + (digit3*b - ) + (digit*b - ) + (digit*b -3 ) The value of this exponent will be determined by the position of the digit. Any Base To Decimal () e.g., 8 to??? Position of the digits. Number to be converted Base = 8 Value in decimal = (*8 ) + (*8 ) = (*8) + (*) = 8 + =

Addition In Binary: Five Cases Case : sum =, no carry out + Case : sum =, no carry out + Case 3: sum =, no carry out + Case 4: sum, carry out = + = (in decimal) + = (in binary) Addition In Binary: Five Cases () Case 5: Sum =, Carry out = + + = 3 (in decimal) = (in binary) +

Subtraction In Binary (4 cases) Case : Case : - - Case 3: - Case 4: - The amount that you borrow equals the base Decimal: Borrow Binary: Borrow You Should Now Know What is meant by a number base. How binary, octal and hex based number systems work and what role they play in the computer. What is overflow, why does it occur and when does it occur. How to/from convert between non-decimal based number systems and decimal. How to perform simple binary math (addition and subtraction).