Numerical Representation of Strings

Slides:



Advertisements
Similar presentations
November 19, 2009Theory of Computation Lecture 19: Calculations on Strings IV 1 Numerical Representation of Strings Correspondingly, we define the following:
Advertisements

Base Conversion COP Practice Problem  Print a String in reverse order:  For example, if we want to print “HELLO” backwards,  we first print:
November 17, 2009Theory of Computation Lecture 18: Calculations on Strings III 1 Numerical Representation of Strings We will now look at several primitive.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
1 Sequences and Mathematical Induction An important task of mathematics is to discover and characterize regular patterns, such as those associated with.
October 1, 2009Theory of Computation Lecture 8: Primitive Recursive Functions IV 1 Primitive Recursive Predicates Theorem 6.1: Let C be a PRC class. If.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
2.1 2 Number Systems Foundations of Computer Science  Cengage Learning.
Computer Science: A Structured Programming Approach Using C1 3-7 Sample Programs This section contains several programs that you should study for programming.
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Positional Number Systems
Number Systems - Part II
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
Chapter 7 Section 7.1 Place Systems.
1 Problem Solving using computers Data.. Representation & storage Representation of Numeric data The Binary System.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
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,
Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in other bases.
Binary Values and Number Systems
Positional Notation 642 in base 10 positional notation is:
Section 2.6 Representation of numbers. Decimal representation (base 10) Given a positive integer X, the decimal representation of X is a string of digits.
Polynomial Division and the Remainder Theorem Section 9.4.
Divisibility Rules and Finding Factors
CPIT 201 Introduction to Computing
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
Lecture 6 Excess Notation. Excess 8 notation indicates that the value for zero is the bit pattern for 8, that is 1000 Excess 8 notation indicates that.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 4 Number Representation and Calculation.
November 12, 2009Theory of Computation Lecture 17: Calculations on Strings II 1 Numerical Representation of Strings First, we define two primitive recursive.
ECE DIGITAL LOGIC LECTURE 2: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/14/2016.
CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases.
CPIT 201 King AbdulAziz University Faculty of Computing & Information Technology Information Technology Department CH 2 Number Systems CPIT 201 Introduction.
DigitValue Denotation NumericValue Denotation 2thousands1,000 0hundreds100 4tens10 8ones1 Computer Organization Basic Computer Concepts Number Systems.
COMPUTER ORGANIZATION 4 TH LECTURE. ASCII Code  ASCII ( American Standard Code for Information Interchange).  Input and output devices that communicate.
October 4, 2016Theory of Computation Lecture 9: A Universal Program I 1Minimalization Example 15: R(x, y) R(x, y) is the remainder when x is divided by.
CPE 201 Digital Design Lecture 2: Digital Systems & Binary Numbers (2)
Introduction To Number Systems
Digital Logic & Design Adil Waheed Lecture 02.
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
What is a byte? What is it? How would you use it?
Positional Notation A positional or place-value notation is a numeral system in which each position is related to the next by a constant multiplier, called.
Floating Point Math & Representation
Exponents Scientific Notation
Multiple variables can be created in one declaration
COMPUTING FUNDAMENTALS
Number Systems Lab session 1 Xuan Guo.
Number Theory and Cryptography
Diagonalization and Reducibility
Numerical Representation of Strings
Copyright © Cengage Learning. All rights reserved.
Fundamentals of Programming I Number Systems
Direct Proof and Counterexample IV
Modular Arithmetic and Change of Base
Digital Logic & Design Lecture 02.
A primer on number representations in computers
William Stallings Computer Organization and Architecture 10th Edition
Direct Proof and Counterexample IV
Theory of Computation Lecture 21: Turing Machines II
Numerical Representation of Strings
Diagonalization and Reducibility
Primitive Recursive Predicates
Computer Organization and Architecture Designing for Performance
Numerical Representation of Strings
Numerical Representation of Strings
Pairing Functions and Gödel Numbers
Numerical Representation of Strings
Binary Values and Number Systems
Theory of Computation Lecture 17: Calculations on Strings II
Theory of Computation Lecture 23: Turing Machines III
Presentation transcript:

Numerical Representation of Strings First, we define two primitive recursive functions where R(x, y) and x / y are defined as in Section 3.7. Basically, R+ and Q+ are the “usual” remainder and quotient functions, except that remainders are now in the range between 1 and y instead of 0 and y –1. November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings So whenever y divides x, we do not have a remainder of 0 but a remainder of y, and accordingly the quotient is one number below the “actual” quotient. Therefore, like with the usual quotient and remainder, it is still true that: x/y = Q+(x, y) + R+(x, y)/y, only that now we have 1  R+(x, y)  y. We will use the functions Q+ and R+ to show how to obtain the subscripts i0, i1, …, ik from any integer x > 0. November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings Let us define: u0 = x um+1 = Q+(um, n) Then we have: u0 = iknk + ik-1nk-1 + … + i1n1 + i0 u1 = iknk-1 + ik-1nk-2 + … + i1 : uk = ik The “remainders” R+ are exactly the values of the im: im = R+(um, n), m = 0, …, k. November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings This is analogous to our usual base-n notation: u0 = x um+1 = Q(um, n) Then we have: u0 = iknk + ik-1nk-1 + … + i1n1 + i0 u1 = iknk-1 + ik-1nk-2 + … + i1 : uk = ik The remainders R are exactly the values of the im: im = R(um, n), m = 0, …, k. November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings Example: Find binary representation of number 13: Then u0 = x = 13; n = 2 u1 = Q(13, 2) = 6; i0 = R(13, 2) = 1 u2 = Q(6, 2) = 3; i1 = R(6, 2) = 0 u3 = Q(3, 2) = 1; i2 = R(3, 2) = 1 u4 = Q(1, 2) = 0; i3 = R(1, 2) = 1 Then w = 1101. Thus k = 3 and we have x = 123 + 122 + 021 + 120 November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings You certainly noticed that in our string representation we used symbols s1, …, sn, while in the everyday number representation we use s0, …, sn-1. So what exactly are the analogies and differences between the two systems? To find out about this, let us look at the following modified set of digits D: D = {s1, …, s10} = {1, 2, 3, 4, 5, 6, 7, 8, 9, X} Here, the X stands for a digit with the value 10, while there is no digit with the value 0. November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings So what is the number x associated with the string w = 76 ? x = 710 + 6 = 76 And what is the number for w = 3X6 ? x = 3100 + 1010 + 6 = 406 Finally, what is the number for w = XX ? x = 1010 + 10 = 110 These examples already suggest that we can use this system in a way quite similar to our “usual” system. November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings Now let us turn this around: What is the string w associated with the number x = 39? w = 39 (as long as x does not contain any 0s, w is the “usual” decimal string representing x) And what is the string for x = 100 ? w = 9X But what is the string for x = 504 ? w = 4X4 Finally, what is the string for x = 0 ? w = 0 (0 is the null string symbol) November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings We can even transfer our elementary arithmetic to the new system: X 4 + 5 9 6  1 0 4 corresponding to + 5 9 6  7 0 0 6 9 X X 2 3 - X 1 X  1 0 2 3 corresponding to - 1 0 2 0  3 3 November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II

Numerical Representation of Strings This applies even to multiplication: 3 X  X 7  4 0 corresponding to  1 0 7  4 2 8 0 2 7 X 3 9 X  4 2 7 X November 14, 2017 Theory of Computation Lecture 18: Calculations on Strings II