Number Representations by Nicole Tobias. Adapted from text(s): PC Assembly Language by Carter and LINUX Assembly Programming by Neveln

Similar documents
Useful Number Systems

CSI 333 Lecture 1 Number Systems

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Computer Science 281 Binary and Hexadecimal Review

NUMBER SYSTEMS. 1.1 Introduction

Positional Numbering System

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

Base Conversion written by Cathy Saxton

Chapter 2. Binary Values and Number Systems

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

=

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

3. Convert a number from one number system to another

THE BINARY NUMBER SYSTEM

Section 1.4 Place Value Systems of Numeration in Other Bases

NUMBER SYSTEMS. William Stallings

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

COMPSCI 210. Binary Fractions. Agenda & Reading

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

Binary, Hexadecimal, Octal, and BCD Numbers

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

2011, The McGraw-Hill Companies, Inc. Chapter 3

Numbering Systems. InThisAppendix...

Lecture 11: Number Systems

Systems I: Computer Organization and Architecture

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Binary Numbers. Binary Octal Hexadecimal

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

CS321. Introduction to Numerical Methods

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

Lecture 2. Binary and Hexadecimal Numbers

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Activity 1: Using base ten blocks to model operations on decimals

Number Systems and Radix Conversion

CS201: Architecture and Assembly Language

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

Number and codes in digital systems

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Binary Adders: Half Adders and Full Adders

Chapter 1: Digital Systems and Binary Numbers

Paramedic Program Pre-Admission Mathematics Test Study Guide

Math Circle Beginners Group October 18, 2015

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points.

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Decimal to Binary Conversion

Binary Representation

The string of digits in the binary number system represents the quantity

CPEN Digital Logic Design Binary Systems

Session 7 Fractions and Decimals

Lecture 8: Binary Multiplication & Division

Number Representation

Sequential Skills. Strands and Major Topics

PREPARATION FOR MATH TESTING at CityLab Academy

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Cyber Security Workshop Encryption Reference Manual

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Classful Subnetting Explained

6 The Hindu-Arabic System (800 BC)

The BBP Algorithm for Pi

Sequences. A sequence is a list of numbers, or a pattern, which obeys a rule.

Chapter 5. Binary, octal and hexadecimal numbers

Classless Subnetting Explained

Pre-Algebra Lecture 6

Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Grade 6 Math Circles. Binary and Beyond

2.5 Zeros of a Polynomial Functions

A Step towards an Easy Interconversion of Various Number Systems

A Prime Investigation with 7, 11, and 13

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

MEP Y9 Practice Book A

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

4.3 TABLE 3 TABLE five

HFCC Math Lab Arithmetic - 4. Addition, Subtraction, Multiplication and Division of Mixed Numbers

Fractions to decimals

Decimals Adding and Subtracting

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

DNA Data and Program Representation. Alexandre David

FRACTIONS COMMON MISTAKES

Preliminary Mathematics

Subnetting Study Guide

Maths Workshop for Parents 2. Fractions and Algebra

Unit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.

Tom wants to find two real numbers, a and b, that have a sum of 10 and have a product of 10. He makes this table.

Playing with Numbers

Integer Operations. Overview. Grade 7 Mathematics, Quarter 1, Unit 1.1. Number of Instructional Days: 15 (1 day = 45 minutes) Essential Questions

Chapter 1. Binary, octal and hexadecimal numbers

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Major Work of the Grade

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

Chapter 4: Computer Codes

TCP/IP Cheat Sheet. A Free Study Guide by Boson Software, LLC

Transcription:

Number Representations by Nicole Tobias Adapted from text(s): PC Assembly Language by Carter and LINUX Assembly Programming by Neveln

Remember the ENIAC? ENIAC did not use the binary system It s arithmetic processor used vacuum tubes were wired together into rings These worked like old desktop adding machine wheels They were base 0 contraptions

Now All electronic computers to arithmetic using the binary system. Sometimes we express descriptions of computer arithmetic in either binary or related systems such as hexadecimal or octal

Decimal, Binary, Hex, etc. NUMBER SYSTEMS

Decimal Base 0 Composed of digits 0 through 9 A total of 0 digits Each digit of a number has a power of 0 associated with it based on the digit s position For example: 3 = x 0 + 3 x 0 + x 0 0

Converting to Decimal General Formula: Value base0 = n n= digit base n Where value of n is the digit position Convert 3 to base 0 value: Column = n = 3 Digit = d = 3 Base = b = 0 0 0

Converting to Decimal Convert 3 to base 0 value: Position = * 0 0 = * = Position = 3 * 0 = 3 * 0 = 30 Position 3 = * 0 = * 00 = 00 Sum = 3! Column = n = 3 Digit = d = 3 Base = b = 0 0 0

Numbers, Numbers, Numbers Computers manipulate numbers by changing the state of switches Transistors = switches Each switch has two states This implies the use of the binary number system

Binary Base numbers are composed of possible digits (0 and ) Digits are associated with a power of based on its position A single binary digit is called a bit. For example 00 = x 4 + x 3 + 0 x + 0 x + x 0 = 6 + 8 + 0 + 0 + = 6 + 8 + = 5 0

Decimal and Binary Decimal Binary Decimal Binary 0 8 9 0 3 4 5 3 6 4 7 5

Decimal and Binary Decimal Binary Decimal Binary 0 0000 8 000 000 9 00 000 0 00 3 00 0 4 000 00 5 00 3 0 6 00 4 0 7 0 5

Convert from Decimal to Binary Convert 5 0 to Binary 5 0 = 5 = r = 6 r 0 6 = 3 r 0 3 = r = 0 r

Convert from Decimal to Binary Convert 5 0 to Binary 5 0 = 5 = r = 6 r 0 6 = 3 r 0 3 = r = 0 r = 00

What about other bases? Octal? Convert 35 0 to base 8: 35 8 = 9 r 3 9 8 = 3 r 5 3 8 = 0 r 3 So, 35 0 = 353 8

General Algorithm To convert from Decimal to another base: (Use division algorithm) Divide the given number by the base repeatedly, until the quotient becomes zero The resulting remainder in reverse order make up the number in the new base

What about base N to base M? How would we convert one base to another since we don t have formulas for that? Transition through decimal! Convert base N to base 0 Then, convert base 0 to base M

Hexadecimal Base 6 Represents digits 0 through 5 Contains the digits 0 through 9 and letters A through F Digit A is equivalent to 0 in decimal, B is, and so on

Decimal, Binary, and Hexadecimal Decimal Binary Hex Decimal Binary Hex 0 0000 8 000 000 9 00 000 0 00 3 00 0 4 000 00 5 00 3 0 6 00 4 0 7 0 5

Decimal, Binary, and Hexadecimal Decimal Binary Hex Decimal Binary Hex 0 0000 0 8 000 8 000 9 00 9 000 0 00 A 3 00 3 0 B 4 000 4 00 C 5 00 5 3 0 D 6 00 6 4 0 E 7 0 7 5 F

Hexadecimal Hex digits have a power of 6 associated with them. Example: Convert BD 6 to decimal: BD 6 = x 6 + B x 6 + D x 6 0 = 70 0 = x 6 + x 6 + 3 x 6 0 = 5 + 76 + 3

Hexadecimal Convert 589 0 to base 6: 589 6 = 36 r 3 36 6 = r 4 6 = 0 r ( D) Therefore, 589 0 = 4D 6

Binary to Hexadecimal Normally you would go from base n to base m by transitioning through decimal Remember: Convert base N to base 0 Then, convert base 0 to base M To make things even more convenient: 6 is a power of

Binary to Hexadecimal 6 is a power of 4, so we can simply group our binary digits by 4s and translate Example 00 00 0000 = 00 = 9 0 = 9 6 00 = 0 0 = A 6 0000 = 0 0 = 0 6 So, 00 00 0000 = 9A0 6

Ok you try. Convert 430 5 to decimal.. Convert 00 0 000 to decimal. 3. Convert # to hexadecimal. 4. Convert 35 0 to base 4 and octal.

Summary Notation Unless otherwise stated in a problem, the base of the number given will be in the subscript. Ex, 345 0 for decimal and A 6 for hex Tips and Tricks (things to watch out for) No digit in your answer should hold a value greater than or equal to the base you are working in. In binary, the first bit determines where the number is even or odd. When switching from a small base to a larger base, the amount of digits needed to represent the value will not increase; likewise, going from large to small, the number of digits needed to represent the value will not decrease.

It doesn t stop there ADDITIONS, AND SUBTRACTIONS

Binary Addition Let s add 3 + 6 In decimal, 3 + 6 = 9 But let s do it in binary: 0 + 00 We have to add column by column

Binary Addition 0 + 00 0 0 First column, + 0 = Second column, 0 + = Third column, + = X? = 0 must carry to next column! Fourth column, + 0 + = must carry to next column! 0

Binary Addition Let s check our answer! 0 + 00 00 Convert the answer and see what we get: 00 = 4 + 0 3 + 0 + + 0 = 6 + 0 + 0 + + = 9 0

Binary Subtraction In-class Demo Refer to Section.4. (Neveln)

Hex Addition In-class Demo We will need the chart again Refer to section.6. (Neveln) Decimal Hex Decimal Hex 0 0 8 8 9 9 0 A 3 3 B 4 4 C 5 5 3 D 6 6 4 E 7 7 5 F

Hex Subtraction In-class Demo We will need the chart again Refer to section.6. (Neveln) Decimal Hex Decimal Hex 0 0 8 8 9 9 0 A 3 3 B 4 4 C 5 5 3 D 6 6 4 E 7 7 5 F

And just because I know you are enjoying this so much FRACTIONS

Fractions in Other Bases In order to use floating point in computer computations, all fractions and powers must be in binary instead of decimal. Decimal fractions, of course, are our everyday standard. Ex,. 5 = + 0 0 = 5 000 = 8 + 5 0 3

Converting Fractions Suppose that we are given a fraction in another base. Use multiplicative process to do the conversion. Ex. We are given.333333 0, and we wish to convert it to a binary fraction.

Converting Fractions Ex. (cont.) We are given.333333 0, and we wish to convert it to a binary fraction. Let.d d d 3 represent the digits in our binary fraction. Let s use the equality:. 33333 = d + d + d 3 3 +

Converting Fractions Ex. (cont.) Let s use the equality:. 33333 = d + d Now solve. Begin by doubling both sides:. 66666 = d + d + d3 + d 3 + Note: The integer parts on both sides must agree. This implies that d = 0 Remove the integer portion and Repeat! 3 +

Converting Fractions Ex. (cont.) We now have. 66666 = d Double both sides again:.33333 = d + d 3 + d3 + d4 + + Note again the integer portion. This implies that d = Remove the integer portion and Repeat!

Converting Fractions Ex. (cont.) We now have. 33333 = d 3 + d4 + By continuing in this manner, you will see that: d 3 = 0, d 4 =, d 5 = 0, d 6 =, and so on So,.33333 0 =.0000

Converting Fractions Will this process work with other bases? Yes!! Convert.33333 0 to base 5 Set up equation:. 33333 = d? + d? + d 3? 3 +

Converting Fractions Will this process work with other bases? Yes!! Convert.33333 0 to base 5 Set up equation:. 33333 = d Now what? 5 + d 5 + d 3 5 3 + Multiply by the equation by 5 (instead of ) since we are going to base five then continue the process described in the prior example.

Converting Fractions.33333 = d 5 + d 5 + d3 5 3 + Multiply by 5:.66666 = d + d 5 + d3 5 + d = Remove the integer. 66666 = d 5 + d3 5 + d4 5 3 + Multiply by 5: 3.33333 = d + d 3 5 + d4 5 + d = 3

Converting Fractions.33333 = d 3 5 + d4 5 + d5 5 3 + Multiply by 5:.66666 = d 3 + d 4 d 3 = Remove the integer Continuing in this way d 4 = 3, d 5 =, d 6 = 3, and so on So, 5 + d5 5 +.33333 0 =.3333 5

ANY QUESTIONS?