6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.

Slides:



Advertisements
Similar presentations
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Advertisements

15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
1 Section 2.5 Integers and Algorithms. 2 Euclidean algorithm for finding gcd Where L is a larger number, and S is a smaller number, to find gcd(L,S):
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
The Binary Number System
Number Systems and Arithmetic
Binary Numbers.
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Binary and Hexadecimal Numbers
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of numbers
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.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 3): The Fundamentals: Algorithms, the.
Number Systems - Part II
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
Introduction to Computer Systems
Computers Organization & Assembly Language
Numbering Systems CS208.
How Computers Work Dr. John P. Abraham Professor UTPA.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Computer Science 111 Fundamentals of Programming I Number Systems.
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
1 Problem Solving using computers Data.. Representation & storage Representation of Numeric data The Binary System.
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,
Integer Representation for People Computer Organization and Assembly Language: Module 3.
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.
Number systems, Operations, and Codes
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Positional Notation 642 in base 10 positional notation is:
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Lecture 1: 8/27/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
29 September 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
CMP 100 Introduction to Computing Lecture Binary Numbers & Logic Operations.
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems
17 November 2015Birkbeck College1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems
20 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
13 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
3 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
17 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
24 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
27 October 2015 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Programmable Logic Controller
Introduction To Number Systems
Introduction to Computer Systems
Binary, Denary, Hexadecimal Conversion Binary Addition
Number Systems.
CSE 504 Discrete Mathematics & Foundations of Computer Science
Number System conversions
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Data Structures Mohammed Thajeel To the second year students
Microprocessor and Assembly Language
Digital Electronics and Microprocessors
Number Systems Rayat Shikshan Sanstha’s
Number Systems Rayat Shikshan Sanstha’s
Presentation transcript:

6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems Autumn 2015 Week 2a: Decimal and Binary Number Representations

Recap: Programs A program is a sequence of instructions. The instructions may refer to memory cells which store values such as integers. In Tom’s computer the memory cells are the boxes. Each memory cell has an address and contents. 15 October 2015Birkbeck College, U. London2

Recap: Running a Program The instructions of the program are executed one by one. When an instruction is executed, the values in the memory cells may change. When the program halts the output is usually the values of selected memory cells. 15 October 2015Birkbeck College, U. London3

Recap: Variables Here are two typical statements in a programming language: p = 0 q = 3+4 Left hand side: the name of a variable Right hand side: an expression Execution: evaluate the right hand side to obtain a number. Store the number in a memory location named by the variable. 6 October 2016Birkbeck College, U. London4

6 October 2015Birkbeck College, U. London5 Exercise from Week 2 Sketch an algorithm that takes as input a strictly positive integer n and outputs an integer k such that

Decimal Representation of Integers  An integer is any whole number, positive or negative, e.g. …, -2, -1, 0, 1, 2, 3,…  In the decimal representation an integer is written as a sum of distinct powers of 10, e.g. 6 October 2015Brookshear, Section 1.56

Properties of Powers of 10 6 October 2015Birkbeck College, U. London7

Places and Powers of 10 The decimal digits are 0,1,2,3,4,5,6,7,8,9. Let s be a string of k decimal digits, 6 October 2015Brookshear, Section 1.58 The digit in the ith place is d i The power of 10 associated with the digit in the ith place is 10 i-1

Example of Place Notation 6 October 2015Birkbeck College, U. London9

Decimal Addition 6 October 2015Birkbeck College, U. London10 Note the carry from the right most column to the next column to the left

Decimal Addition in Terms of Powers of 10 6 October 2015Birkbeck College, U. London11

Curious Properties of the Decimal Representation A number is divisible by 3 if and only if the sum of its decimal digits is divisible by 3. A number is divisible by 11 if and only if the sum of its decimal digits in the even places minus the sum of its decimal digits in the odd places is divisible by October 2015Birkbeck College, U. London12

6 October 2015Birkbeck College, U. London13 Bits and Bytes A bit (binary digit) takes the value 0 or 1. A bit string is a list of bits in a fixed order. A byte is a bit string of length 8. Leftmost bit: most significant bit Rightmost bit: least significant bit Megabyte: 10 6 bytes (or sometimes 2 20 bytes).

6 October 2015Birkbeck College, U. London14 Computer Data Number: bit string Person’s name: bit string Memory address: bit string Current time: bit string All data inside a computer are recorded as bit strings Corollary: a bit string on its own can mean anything

6 October 2015Brookshear, Section Binary Representation of Integers 1011 representation onetwoeightfour Binary (base two) system The binary digits are 0, 1 An integer is represented as a sum of powers of 2

6 October 2015Birkbeck College, U. London16 Notation BinaryInteger[11101]=DecimalInteger[29]. BinaryInteger[ ]=DecimalInteger[101].

6 October 2015Birkbeck College, U. London17 Some Integers Binary IntegerDecimal Integer Power of 2: BinaryInteger[10…0]

6 October 2015Brookshear, Section Conversion from Binary to Decimal BinaryInteger[b(n)….b(1)]= DecimalInteger[b(n)2 n-1 +b(n-1)2 n-2 +…+b(1)] Example: BinaryInteger[1101]= DecimalInteger[1x2 3 +1x2 2 +0x2 1 +1] = DecimalInteger[8+4+1]= DecimalInteger[13]

6 October 2015Brookshear, Section Addition of Binary Bits 1+1 = 0 carry = = = 0

6 October 2015Birkbeck College, U. London20 Example of Binary Addition ( )+(2 1 +1) = 2 3 +(1+1)x = 2 3 +(1+1)x = 2 3 +(1+1+1)x2 1 = 2 3 +(2+1)x2 1 = ==== 1110

6 October 2015Birkbeck College, U. London21 Examples Convert DecimalInteger[13] to a binary integer. Convert BinaryInteger[10010] to a decimal integer. Add BinaryInteger[1101] to BinaryInteger[110]

6 October 2015Birkbeck College, U. London22 Multiplication of Binary Numbers Multiply by a power of 2: add zeros on the right, e.g x 100 = x 10 = 1100  In general, reduce to multiplication by a sum of powers of 2, e.g. 1011x11 = 1011x(10+1) = 1011x x1 = =

6 October 2015Brookshear, Section Conversion to Binary Input: non-negative integer m Output: bit string b such that m= BinaryInteger[b] 1.If(m==0, Output {0}; Halt) 2.b = {} /* empty bit string */ 3.While(m>0) 4. Divide m by 2, to give quotient q, remainder r 5. m = q 6. b = Attach r on the left hand side of b 7.EndWhile 8.Output b 9.Halt

6 October 2015Brookshear, Section Conversion from Binary to Decimal Input: non-empty bit string b Output: decimal integer m such that m = BinaryInteger[b] 1.m = 0; 2.While (b is not empty) 3. r = left most bit of b 4. m = m+r 2 Length[b]-1 5. b = b with left most bit deleted; 6.EndWhile; 7.Output m; 8.Halt;

6 October 2015Brookshear, Section Hexadecimal Representation 0000=0, 0001=1, 0010=2, 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 Example BinaryInteger[ ] = = HexadecimalInteger[AB6B4] BinaryInteger[]

Hexadecimal Addition 6 October 2015Birkbeck College, U. London26 carry from column 1 to column 2