NUMBER SYSTEMS. William Stallings



Similar documents
Useful Number Systems

CSI 333 Lecture 1 Number Systems

Base Conversion written by Cathy Saxton

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

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

Section 1.4 Place Value Systems of Numeration in Other Bases

Computer Science 281 Binary and Hexadecimal Review

=

Positional Numbering System

Lecture 11: Number Systems

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

The gas can has a capacity of 4.17 gallons and weighs 3.4 pounds.

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

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

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

Introduce Decimals with an Art Project Criteria Charts, Rubrics, Standards By Susan Ferdman

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

YOU MUST BE ABLE TO DO THE FOLLOWING PROBLEMS WITHOUT A CALCULATOR!

Preliminary Mathematics

Lecture 2. Binary and Hexadecimal Numbers

The Crescent Primary School Calculation Policy

Addition Methods. Methods Jottings Expanded Compact Examples = 15

CS321. Introduction to Numerical Methods

Fractions to decimals

Binary, Hexadecimal, Octal, and BCD Numbers

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

Number Systems and Radix Conversion

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left.

NUMBER SYSTEMS. 1.1 Introduction

Stanford Math Circle: Sunday, May 9, 2010 Square-Triangular Numbers, Pell s Equation, and Continued Fractions

CHAPTER 5 Round-off errors

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

THE BINARY NUMBER SYSTEM

Number Representation

Math Circle Beginners Group October 18, 2015

CPEN Digital Logic Design Binary Systems

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

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

Multiplication. Year 1 multiply with concrete objects, arrays and pictorial representations

Paramedic Program Pre-Admission Mathematics Test Study Guide

1.4 Compound Inequalities

Solve addition and subtraction word problems, and add and subtract within 10, e.g., by using objects or drawings to represent the problem.

Decimal Notations for Fractions Number and Operations Fractions /4.NF

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

Dr Brian Beaudrie pg. 1

8 Divisibility and prime numbers

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

Arithmetic 1 Progress Ladder

Pre-Algebra Lecture 6

Chapter 4: Computer Codes

Chapter 4 -- Decimals

26 Integers: Multiplication, Division, and Order

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

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Lecture 8: Binary Multiplication & Division

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix:

COMPSCI 210. Binary Fractions. Agenda & Reading

3. Convert a number from one number system to another

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Binary Adders: Half Adders and Full Adders

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

Math 0306 Final Exam Review

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

Properties of sequences Since a sequence is a special kind of function it has analogous properties to functions:

5.4 Solving Percent Problems Using the Percent Equation

Summary Of Mental Maths Targets EYFS Yr 6. Year 3. Count from 0 in multiples of 4 & 8, 50 & 100. Count back in 100s, 10s, 1s eg.

1. The Fly In The Ointment

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

Linear Programming Notes V Problem Transformations

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Section 4.2: The Division Algorithm and Greatest Common Divisors

MATH10040 Chapter 2: Prime and relatively prime numbers

Continued Fractions and the Euclidean Algorithm

Decimals and other fractions

**Unedited Draft** Arithmetic Revisited Lesson 5: Decimal Fractions or Place Value Extended Part 3: Multiplying Decimals

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

Unit 6 Number and Operations in Base Ten: Decimals

Grade 6 Math Circles. Binary and Beyond

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

Basic numerical skills: FRACTIONS, DECIMALS, PROPORTIONS, RATIOS AND PERCENTAGES

Mathematical goals. Starting points. Materials required. Time needed

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

Exponents. Exponents tell us how many times to multiply a base number by itself.

Scope and Sequence KA KB 1A 1B 2A 2B 3A 3B 4A 4B 5A 5B 6A 6B

Zeros of Polynomial Functions

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

5 Mathematics Curriculum

5.1 Radical Notation and Rational Exponents

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

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

Solutions of Linear Equations in One Variable

The BBP Algorithm for Pi

Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving

Memory is implemented as an array of electronic switches

numerical place value additional topics rounding off numbers power of numbers negative numbers addition with materials fundamentals

Unit 11 Fractions and decimals

6 The Hindu-Arabic System (800 BC)

Introduction to Decimals

JobTestPrep's Numeracy Review Decimals & Percentages

CS201: Architecture and Assembly Language

Transcription:

NUMBER SYSTEMS William Stallings The Decimal System... The Binary System...3 Converting between Binary and Decimal...3 Integers...4 Fractions...5 Hexadecimal Notation...6 This document available at WilliamStallings.com/StudentSupport.html Copyright 000 William Stallings -1-

The Decimal System In everyday life we use a system based on decimal digits (0, 1,, 3, 4, 5, 6, 7, 8, 9) to represent numbers and refer to the system as the decimal system. Consider what the number 83 means. It means eight tens plus three: 83 = (8 10) + 3 The number 478 means four thousands, seven hundreds, two tens, plus eight: 478 = (4 1000) + (7 100) + ( 10) + 8 The decimal system is said to have a base, or radix, of 10. This means that each digit in the number is multiplied by 10 raised to a power corresponding to that digit s position: 83 = (8 10 1 ) + (3 10 0 ) 478 = (4 10 3 ) + (7 10 ) + ( 10 1 ) + (8 10 0 ) The same principle holds for decimal fractions but negative powers of 10 are used. Thus, the decimal fraction 0.56 stands for tenths plus 5 hundredths plus 6 thousandths: 0.56 = ( 10 1 ) + (5 10 ) + (6 10 3 ) A number with both an integer and fractional part has digits raised to both positive and negative powers of 10: 47. 56 = (4 10 ) + (7 10 1 ) + ( 10 0 ) + ( 10 1 ) + (5 10 ) + (6 10 3 ) In general, for the decimal representation of X = {... d d 1 d 0.d 1 d d 3...}, the value of X is X = i d i 10 i --

The Binary System In the decimal system, 10 different digits are used to represent numbers with a base of 10. In the binary system, we have only two digits, 1 and 0. Thus, numbers in the binary system are represented to the base. To avoid confusion, we will sometimes put a subscript on a number to indicate its base. For example, 83 10 and 478 10 are numbers represented in decimal notation, or more briefly, decimal numbers. The digits 1 and 0 in binary notation have the same meaning as in decimal notation: 0 = 0 10 1 = 1 10 To represent larger numbers, as with decimal notation, each digit in a binary number has a value depending on its position: 10 = (1 1 ) + (0 0 ) = 10 11 = (1 1 ) + (1 0 ) = 3 10 100 = (1 ) + (0 1 ) + (0 0 ) = 4 10 and so on. Again, fractional values are represented with negative powers of the radix: 1001.101 = 3 + 0 + 1 + 3 = 9.65 10 In general, for the binary representation of Y = {... b b 1 b 0.b 1 b b 3...}, the value of Y is Y = i b i i Converting between Binary and Decimal It is a simple matter to convert a number from binary notation to decimal notation. In fact, we showed several examples in the previous subsection. All that is required is to multiply each binary digit by the appropriate power of and add the results. To convert from decimal to binary, the integer and fractional parts are handled separately. -3-

Integers For the integer part, recall that in binary notation, an integer represented by b m 1 b m b b 1 b 0 b i = 0 or 1 has the value (b m 1 m 1 ) +(b m m ) + + (b 1 1 ) + b 0 Suppose it is required to convert a decimal integer N into binary form. If we divide N by, in the decimal system, and obtain a quotient N 1 and a remainder R 0, we may write N = N 1 + R 0 R 0 = 0 or 1 Next, we divide the quotient N 1 by. Assume that the new quotient is N and the new remainder R 1. Then N 1 = N + R 1 R 1 = 0 or 1 so that N = (N + R 1 ) + R 0 = (N ) + (R 1 1 ) + R 0 If next N = N 3 + R we have N = (N 3 3 ) + (R ) + (R 1 1 ) + R 0 Because N > N 1 > N..., continuing this sequence will eventually produce a quotient N m 1 = 1 (except for the decimal integers 0 and 1, whose binary equivalents are 0 and 1, respectively) and a remainder R m, which is 0 or 1. Then N = (1 m 1 ) + (R m m ) +... + (R ) + (R 1 1 ) + R 0-4-

which is the binary form of N. Hence, we convert from base 10 to base by repeated divisions by. The remainders and the final quotient, 1, give us, in order of increasing significance, the binary digits of N. Figure 1 shows two examples. Fractions For the fractional part, recall that in binary notation, a number with a value between 0 and 1 is represented by has the value 0.b 1 b b 3 b i = 0 or 1 (b 1 1 ) + (b ) + (b 3 3 ) This can be rewritten as 1 (b 1 + 1 (b + 1 (b 3 + This expression suggests a technique for conversion. Suppose we want to convert the number F (0 < F < 1) from decimal to binary notation. We know that F can be expressed in the form F = 1 (b 1 + 1 (b + 1 (b 3 + If we multiply F by, we obtain: F = b 1 + 1 (b + 1 (b 3 + From this equation, we see that the integer part of ( F), which must be either 0 or 1 because 0 < F < 1, is simply b 1. So we can say ( F) = b 1 + F 1, where 0 < F 1 < 1 and where F 1 = 1 (b + 1 (b 3 + 1 (b 4 + To find b, we repeat the process. Therefore, the conversion algorithm involves repeated multiplication by. At each step, the fractional part of the number from the previous step is multiplied by. The digit to the left of the decimal point in the product will be 0 or 1 and -5-

contributes to the binary representation, starting with the most significant digit. The fractional part of the product is used as the multiplicand in the next step. Figure shows two examples. This process is not necessarily exact; that is, a decimal fraction with a finite number of digits may require a binary fraction with an infinite number of digits. In such cases, the conversion algorithm is usually halted after a prespecified number of steps, depending on the desired accuracy. Hexadecimal Notation Because of the inherent binary nature of digital computer components, all forms of data within computers are represented by various binary codes. However, no matter how convenient the binary system is for computers, it is exceedingly cumbersome for human beings. Consequently, most computer professionals who must spend time working with the actual raw data in the computer prefer a more compact notation. What notation to use? One possibility is the decimal notation. This is certainly more compact than binary notation, but it is awkward because of the tediousness of converting between base and base 10. Instead, a notation known as hexadecimal has been adopted. Binary digits are grouped into sets of four. Each possible combination of four binary digits is given a symbol, as follows: 0000 = 0 0001 = 1 0010 = 0011 = 3 0100 = 4 0101 = 5 0110 = 6 0111 = 7 1000 = 8 1001 = 9 1010 = A 1011 = B 1100 = C 1101 = D 1110 = E 1111 = F Because 16 symbols are used, the notation is called hexadecimal, and the 16 symbols are the hexadecimal digits. A sequence of hexadecimal digits can be thought of as representing an integer in base 16. Thus, C 16 = ( 16 16 1 ) + (C 16 16 0 ) = ( 10 16 1 ) + (1 10 16 0 ) = 44-6-

Hexadecimal notation is used not only for representing integers. It is also used as a concise notation for representing any sequence of binary digits, whether they represent text, numbers, or some other type of data. The reasons for using hexadecimal notation are 1. It is more compact than binary notation.. In most computers, binary data occupy some multiple of 4 bits, and hence some multiple of a single hexadecimal digit. 3. It is extremely easy to convert between binary and hexadecimal. As an example of the last point, consider the binary string 110111100001. This is equivalent to 1101 1110 0001 = DE1 16 D E 1 This process is performed so naturally that an experienced programmer can mentally convert visual representations of binary data to their hexadecimal equivalent without written effort -7-

11 Quotient Remainder = 5 1 5 1 = 1 = 1 0 = 0 1 1011 = 11 10 (a) 11 10 1 10 Quotient Remainder = 10 1 = 5 0 5 1 = 1 = 1 0 = 0 1 10101 = 1 10 (b) 1 10 Figure 1 Examples of Converting from Decimal Notation to Binary Notation for Integers

Product Integer Part 0.81 = 1.6 1 0.110011 0.6 = 1.4 1 0.4 = 0.48 0 0.48 = 0.96 0 0.96 = 1.9 1 0.9 = 1.84 1 (a) 0.81 10 = 0.11011 (approximately) Product Integer Part 0.5 = 0.5 0 0.01 0.5 = 1.0 1 (B) 0.5 10 = 0.01 (exactly) Figure Examples of Converting from Decimal Notation to Binary Notation for Fractions