James Tam Beyond Base 10: Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and.

Slides:



Advertisements
Similar presentations
DATA REPRESENTATION CONVERSION.
Advertisements

James Tam Beyond base 10: Non-decimal based number system What exactly is decimal? How do other number systems work (binary, octal and hex) How to convert.
James Tam Beyond Base 10: Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and.
James Tam Beyond Base 10: Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and.
James Tam Beyond Base 10: Non-decimal Based Number Systems What exactly is decimal? How do other number systems work (binary, octal and hex) How to convert.
James Tam Beyond Base 10: Non-decimal Based Number Systems What is the decimal based number system? How does the binary number system work Converting between.
James Tam Number Representations You will learn about the binary number system and how subtractions are performed on the computer.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Introduction to Programming with Java, for Beginners
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:
James Tam Non decimal math: doing math with non-base 10 number systems Addition, subtraction and multiplication with binary, octal and hexadecimal.
James Tam Beyond Base 10: Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and.
28-Jun-15 Number Systems. 2 Bits and bytes A bit is a single two-valued quantity: yes or no, true or false, on or off, high or low, good or bad One bit.
Data Representation in Computers
Lesson 2 0x Coding ASCII Code.
 Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal.
Binary Numbers.
Number Systems and Codes
Number Systems.
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
Computers Organization & Assembly Language
Numbering Systems CS208.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
James Tam Number systems and logic What is the decimal based number system How does the binary number system work Converting between decimal and binary.
IT253: Computer Organization
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Chapter 3 Section 1 Number Representation Modern cryptographic methods, unlike the classical methods we just learned, are computer based. Representation.
HOW COMPUTERS MANIPULATE DATA Chapter 1 Coming up: Analog vs. Digital.
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 Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
Number Systems Ron Christensen CIS 121.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
CISC1100: Binary Numbers Fall 2014, Dr. Zhang 1. Numeral System 2  A way for expressing numbers, using symbols in a consistent manner.  " 11 " can be.
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
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
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.
Number Systems. ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Nat 4/5 Computing Science Data Representation Lesson 3: Storing Text
Some basic concepts underlying computer archi­tecture
Introduction To Number Systems
NUMBER SYSTEMS.
Data Representation ICS 233
Binary 1 Basic conversions.
Data Representation.
Discrete Mathematics Numbering System.
3.1 Denary, Binary and Hexadecimal Number Systems
Digital Systems and Number Systems
Data Representation Binary Numbers Binary Addition
CSCI 198: Lecture 4: Data Representation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 : INTRODUCTION
CSCI 161: Lecture 4: Data Representation
Tools of Web Development 1: Module A: Numbering Systems
Number Systems.
Numbering System TODAY AND TOMORROW 11th Edition
Digital Electronics and Microprocessors
COMS 161 Introduction to Computing
Chapter 2: Number Systems
COMS 161 Introduction to Computing
Chapter Four Data Representation in Computers By Bezawit E.
Beyond Base 10: Non-decimal Based Number Systems
Presentation transcript:

James Tam Beyond Base 10: 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 non- decimal number systems to decimal Binary math

James Tam What Is Decimal? Base unique symbols are used to represent values : 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(10) - 1

James Tam Binary Base two Employs two unique symbols (0 and 1) Largest decimal value that can be represented by 1 binary digit = 1 = base(2) - 1

James Tam Table Of Binary Values Decimal valueBinary valueDecimal valueBinary value

James Tam Why Bother With Binary? Representing information ASCII (American Standard Code for Information Interchange) Unicode It's the language of the computer

James Tam Representing Information: ASCII DecimalBinaryASCII 0 – – Invisible (control characters) 32 – – Punctuation, mathematical operations – Characters – – Comparators and other miscellaneous characters : ; – Alphabetic (upper case A - Z) 91 – – More miscellaneous characters [ \ ] ^ _ ' 97 – – Alphabetic (lower case a - z) 123 – More miscellaneous characters { | } ~ DEL

James Tam Representing Information: ASCII (2) Uses 7 bits to represent characters Max number of possibilities = 2 7 = 128 characters that can be represented e.g., 'A' is 65 in decimal or in binary. In memory it looks like this:

James Tam Representing Information: Unicode Uses 16 bits (or more) to represent information Max number of possibilities = 2 16 = characters that can be represented (more if more bits are used)

James Tam Computer Programs 1) A programmer writes a computer program 2) 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. Binary is the language of the computer

James Tam Octal Base eight Employs eight unique symbols (0 - 7) Largest decimal value that can be represented by 1 octal digit = 7 = base(8) - 1

James Tam Table Of Octal Values Decimal valueOctal valueDecimal valueOctal value

James Tam Why Octal? ? ? ?

James Tam Why Octal? (2) MachineOctal languagevalue

James Tam Hexadecimal (Hex) Base sixteen Employs sixteen unique symbols (0 – 9, followed by A - F) Largest decimal value that can be represented by 1 hex digit = 15

James Tam Table of Hex Values Decimal valueHexadecimal value Decimal valueHexadecimal value A 2211B 3312C 4413D 5514E 6615F

James Tam Why Hexadecimal? ? Or ?

James Tam Why Hexadecimal? (2) MachineHexadecimal languagevalue C E0 Example from Family Assembly Language by Clements A.

James Tam Summary (Decimal, Binary, Octal, Hex) DecimalBinaryOctalHexDecimalBinaryOctalHex A B C D E F

James Tam High Vs. Low Level Machine language Low level programming language Computer hardware High level programming language Binary Assembly E.g., Pascal, Java, C++ Human languages E.g., English, French, Spanish, Chinese, German etc. High level Low level

James Tam Overflow: A Real World Example You can only represent a finite number of values

James Tam Overflow: Binary Occurs when you don't have enough bits to represent a value (“wraps around” to zero) Binary (1 bit) Value Binary (2 bits) Value Binary (3 bits) Value : : :

James Tam Arbitrary Number Bases Base N Employs N unique symbols Largest decimal value that can be represented by 1 digit = Base (N) - 1

James Tam 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

James Tam Binary To Octal 3 binary digits equals one octal digit (remember 2 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 = ???

James Tam Octal To Binary 1 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 = ???

James Tam Binary To Hexadecimal 4 binary digits equals one hexadecimal digit (remember 2 4 =16) 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., = ???

James Tam Hexadecimal To Binary 1 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 16 = ???

James Tam Octal To Hexadecimal Convert to binary first! e.g., 25 8 to ???

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

James Tam Hexadecimal To Octal e.g., to ???

James Tam Hexadecimal To Octal e.g., to ??? 8 Regroup in groups of Add any leading zeros that are needed (in this case one)

James Tam Decimal To Any Base Split up the integer and the fractional portions 1)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.

James Tam Decimal To Any Base (2) 2)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.

James Tam Decimal To Any Base (2) e.g., 9 10 to ??? 2 9 / 2: q = 4 r = / 2: q =2 r = /2: q = 1 r = Stop dividing! (quotient less than target base) 1 1

James Tam Any Base To Decimal Multiply each digit by the base raised to some exponent 1 and sum the resulting products. i.e. d7 d6 d5 d4. d3 d2 d1 b Base = b 1 The value of this exponent will be determined by the position of the digit. Number to be converted Position of digits Value in decimal = (digit7*b 3 ) + (digit6*b 2 ) + (digit5*b 1 ) + (digit4*b 0 ) + (digit3*b -1 ) + (digit2*b -2 ) + (digit1*b -3 )

James Tam Any Base To Decimal (2) e.g., 12 8 to ??? Position of the digits Number to be converted = Base = 8 Value in decimal = (1*8 1 ) + (2*8 0 ) = (1*8) + (2*1) = 10 10

James Tam Addition In Binary: Five Cases Case 1: sum = 0, no carry out Case 2: sum = 1, no carry out Case 3: sum = 1, no carry out Case 4: sum 0, carry out = = 2 (in decimal) = 10 (in binary) 1

James Tam Addition In Binary: Five Cases (2) Case 5: Sum = 1, Carry out = = 3 (in decimal) = 11 (in binary) 1 1 1

James Tam Subtraction In Binary (4 cases) Case 1: Case 2: Case 3: Case 4: The amount that you borrow equals the base Decimal: Borrow 10 Binary: Borrow 2 2 1

James Tam 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).