Computer Science 1000: Part #3. Binary Numbers

Similar documents
MACHINE LEVEL REPRESENTATION OF DATA

Objectives. Connecting with Computer Science 2

CHW 261: Logic Design

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Digital Fundamentals

COMP Overview of Tutorial #2

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Software and Hardware

Introduction to Computer Science-103. Midterm

Number representations

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Chapter 2 Bits, Data Types, and Operations

Introduction to Numbering Systems

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

CS & IT Conversions. Magnitude 10,000 1,

Beyond Base 10: Non-decimal Based Number Systems

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Chapter 1 Review of Number Systems

CMPS 10 Introduction to Computer Science Lecture Notes

Chapter 2 Bits, Data Types, and Operations

Number Systems CHAPTER Positional Number Systems

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Introduction to Computers and Programming. Numeric Values

Number System. Introduction. Decimal Numbers

Electronic Data and Instructions

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

COMP2121: Microprocessors and Interfacing. Number Systems

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Purpose of Chapter. External Representation of Information.

Beyond Base 10: Non-decimal Based Number Systems

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Chapter 3: Arithmetic for Computers

Number Systems. Both numbers are positive

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Invitation to Computer Science, C++ Version, Third Edition

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Signed umbers. Sign/Magnitude otation

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Data Representations

Chapter 2. Data Representation in Computer Systems

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

ECE 372 Microcontroller Design Assembly Programming Arrays. ECE 372 Microcontroller Design Assembly Programming Arrays

Bits, bytes, binary numbers, and the representation of information

Data Representations & Arithmetic Operations

Final Labs and Tutors

Chapter 2 Bits, Data Types, and Operations

Bits. Binary Digits. 0 or 1

Data Representation 1

DATA REPRESENTATION. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift, Jaipur Region. Based on CBSE curriculum Class 11. Neha Tyagi, KV 5 Jaipur II Shift

Introduction to Computer Science (I1100) Data Storage

Octal and Hexadecimal Integers

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

What Is It? Instruction Register Address Register Data Register

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

IBM 370 Basic Data Types

UNIT 7A Data Representation: Numbers and Text. Digital Data

BINARY SYSTEM. Binary system is used in digital systems because it is:

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

CMPE223/CMSE222 Digital Logic Design. Positional representation

Digital Computers and Machine Representation of Data

Lecture 2: Number Systems

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

The. Binary. Number System

CHAPTER 2 Number Systems

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

TOPIC: NUMBER SYSTEMS

Digital Fundamentals

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Level ISA3: Information Representation

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Chapter 4: Computer Codes. In this chapter you will learn about:

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Digital Fundamentals

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

The type of all data used in a C++ program must be specified

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

These notes are designed to provide an introductory-level knowledge appropriate to understanding the basics of digital data formats.

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

CS311 Lecture: Representing Information in Binary Last revised 8/2707

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems

Basic data types. Building blocks of computation

Internal Data Representation

Divide: Paper & Pencil

Digital Systems and Binary Numbers

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

Transcription:

Computer Science 1000: Part #3 Binary Numbers COMPUTER ORGANIZATION: AN OVERVIEW AN HISTORICAL INTERLUDE REPRESENTING NUMBERS IN BINARY REPRESENTING TEXT, SOUND, AND PICTURES IN BINARY

Computer Organization: An Overview The Von Neumann Architecture (1945) data instructions results memory processor person I/O interface computer Also known as the stored-program architecture

Computer Organization: An Overview (Cont d) What is a Computer (Really)? A computer is a machine that (1) stores a very, very large number of numbers and (2) performs very, very long specified sequences of very simple operations on these numbers (3) very, very fast.

Computer Organization: An Overview (Cont d) Guiding Principles There are two main principles of computer organization: 1. Levels of Abstraction: A complex system can be described as a hierarchy of levels, where collections of interacting entities at one level are encapsulated in a single entity at a higher level (see Textbook, Figure 5.1, p. 223). 2. Internal vs. External Representation: Within a complex system, the representations used internally by an entity to perform its functions need not be those with which it interacts externally with other entities.

A Historical Interlude: The Glory of Decimal Numbers Decimal numbers (base-10 positional notation) were developed around 1200 years ago in the Middle East, Rapidly replaced older non-positional systems, e.g., MCMXXXVII (1000 + (1000 100) + 10 + 10 + 10 + 5 + 1 + 1) vs. 1937 10 ((1 10 3 ) + (9 10 2 ) + (3 10 1 ) + (7 10 0 ))

A Historical Interlude: (Cont d) The Glory of Decimal Numbers (Cont d) Position Decimal 1 10 0 1 2 10 1 10 3 10 2 100 4 10 3 1000 5 10 4 10, 000 6 10 5 100, 000 7 10 6 1, 000, 00 8 10 7 10, 000, 000 9 10 8 100, 000, 000 10 10 9 1, 000, 000, 000

A Historical Interlude: (Cont d) The Tyranny of Decimal Numbers Centrality of decimal numbers in mathematics led to their being both the internal and external representations of numbers in the earliest computing machines, e.g., the 1642 addition machine of Blaise Pascal (1623 1662).

A Historical Interlude: (Cont d) The Tyranny of Decimal Numbers (Cont d) This reliance on decimal internal representations continued into the early days of electromechanical computing. Harvard Mark I (1944) Zuse Z3 (1941) Colossus (1944)

A Historical Interlude: (Cont d) The Glory of Binary Numbers The emergence of fully electronic computing in the late 1940s led to binary (base-2 positional notation) internal representations of numbers. 167 10 ((1 10 2 ) + (6 10 1 ) + (7 10 0 )) vs. 10100111 2 ((1 2 7 ) + (0 2 6 ) + (1 2 5 ) + (0 2 4 )+ (0 2 3 ) + (1 2 2 ) + (1 2 1 ) + (1 2 0 ))

A Historical Interlude: (Cont d) The Glory of Binary Numbers (Cont d) Position Decimal Binary 1 10 0 1 2 0 1 2 10 1 10 2 1 2 3 10 2 100 2 2 4 4 10 3 1000 2 3 8 5 10 4 10, 000 2 4 16 6 10 5 100, 000 2 5 32 7 10 6 1, 000, 00 2 6 64 8 10 7 10, 000, 000 2 7 128 9 10 8 100, 000, 000 2 8 256 10 10 9 1, 000, 000, 000 2 9 512 In binary, need 10 digits to represent a factor of 1000.

A Historical Interlude: (Cont d) The Glory of Binary Numbers (Cont d) To convert a binary number to its decimal equivalent, add up the powers of two corresponding to the 1 s in the number, e.g., 110101 2 = 2 5 + 2 4 + 2 2 + 2 0 = 32 + 16 + 4 + 1 = 53 10 10101100 2 = 2 7 + 2 5 + 2 3 + 2 2 = 128 + 32 + 8 + 4 = 172 10

A Historical Interlude: (Cont d) The Glory of Binary Numbers (Cont d) To convert a decimal number to its binary equivalent, repeatedly divide by two and read the remainder digits in reverse (from last to first), e.g., Quotient Remainder 53/2 26 1 26/2 13 0 13/2 6 1 = 110101 2 6/2 3 0 3/2 1 1 1/2 0 1

A Historical Interlude: (Cont d) The Glory of Binary Numbers (Cont d) Done for reliability, e.g., distinguishing between and maintaining two voltage levels is much easier to do than distinguishing between and maintaining ten voltage levels. Decimal Binary (0) +0 +0 (0) (1) +5 (2) +10 (3) +15 (4) +20 vs. (5) +25 (6) +30 (7) +35 (8) +40 (9) +45 +45 (1)

Representing Numbers in Binary Basic base-2 positional notation (unsigned binary) can handle the representation and addition of positive integers, e.g., 1 1 1 1 1 1 carry 1 1 0 1 1 2 2 7 10 + 1 1 0 1 2 + 1 3 10 1 0 1 0 0 0 2 4 0 10... But what about negative integers?...

Representing Numbers in Binary: (Cont d) Sign/Magnitude Representation Use leftmost bit to encode sign (+ve as 0, -ve as 1), e.g., Negative Positive 0 10 100 2 000 2 +0 10 1 10 101 2 001 2 +1 10 2 10 110 2 010 2 +2 10 3 10 111 2 011 2 +3 10 Has two representations of zero, and both can arise during arithmetic; this causes problems for computer designers.

Representing Numbers in Binary: (Cont d) Two s Complement Representation Represent negative number by taking unsigned binary positive version and starting after rightmost 1, complement every bit to the left (see also Textbook, p. 160), e.g., Negative Positive 000 2 +0 10 1 10 111 2 001 2 +1 10 2 10 110 2 010 2 +2 10 3 10 101 2 011 2 +3 10 4 10 100 2 Has one zero but more negative than positive numbers.

Representing Numbers in Binary: (Cont d) Fractional Numbers Store in scientific notation (M B E ) where base B = 2, mantissas (M) and exponents (E) are stored in signed binary notation, and mantissas are normalized, e.g.,

Representing Numbers in Binary: (Cont d) Fractional Numbers (Cont d) Example: Representing 5.75 10 as a fractional number 5 10 = 4 + 1 = 2 2 + 2 0 = 101 2 and.75 10 = 1/2 + 1/4 == 2 1 + 2 2 =.11 2 ; Therefore, 5.75 10 = 101.11 2 Normalize 101.11 2, e.g., 101.11 2 = 101.11 2 2 0 = 10.111 2 2 1 = 1.0111 2 2 2 =.10111 2 2 3 Encode M = +.10111 2 and E = +3 10 = +11 2, i.e., 0 + 00010111 + 0 + 000011

Representing Numbers in Binary: (Cont d) More Compact Representations Long binary numbers represented more compactly in octal (8 digit; 0, 1,..., 7) or hexadecimal (16 digit; 0, 1,..., 9, A, B C, D, E, F), e.g., 7 7 1 1 7711 8 1 1 1 1 1 1 0 0 1 0 0 1 2 F C 9 FC9 16 1 1 1 1 1 1 0 0 1 0 0 1 2

Representing Numbers in Binary: (Cont d) More Compact Representations (Cont d) To convert an octal (hexadecimal) number to its decimal equivalent, add up the powers of eight (sixteen) multiplied by non-zero digits, e.g., 302 8 = (3 8 2 ) + (2 8 0 ) = (3 64) + 2 = 194 10 A9 16 = (10 16 1 ) + (9 16 0 ) = 160 + 9 = 169 10

Representing Numbers in Binary: (Cont d) More Compact Representations (Cont d) To convert a decimal number to its octal (hexadecimal) equivalent, repeatedly divide by eight (sixteen) and read the remainder digits in reverse (from last to first), e.g., Quotient Remainder 194/8 24 2 24/8 3 0 = 302 8 3/8 0 3 169/16 10 9 10/16 0 10 = A9 16

Binary Computer Memory What does 0100000101011000110001111 mean?

Binary Computer Memory (Cont d) Things that binary computer memory does well: 01000#00101#01100#01100#01111 Sounds Pictures Numbers 8, 5, 12, 12, 15 Text "HELLO"

Representing Text in Binary Associate individual symbols with unsigned binary numbers; these symbols may not be printable but rather instructions to I/O interface devices, e.g., control characters. Original ASCII and EBCDIC standards used 7 and 8 bits to represent 128 and 256 symbols (see Table 4.3 in textbook for part of ASCII standard). Original UNICODE standard used 16 bits to represent 65,000 symbols; embedded original ASCII standard in lowest 128 codes. UNICODE subsequently extended to 32 bits; can accommodate two billion symbols.

Representing Sound in Binary Encode periodic audio signal samples as integers. 40,000 samples/sec suffices for human hearing.

Representing Pictures in Binary Reduce picture to grid of picture elements (pixels). Encode pixel values as one or more integers, e.g., single bits (B/W (see below)), 8-value gray scale (B/W), triplets of 256-value red / green / blue intensities (color).

Binary Computer Memory Redux Things that binary computer memory doesn t do so well: Arbitrary Fractional Numbers 1/3 0.33 1/3 0.33 Detailed Pictures Earth??? 1/3 1 0.33 0.99

... And If You Liked This... MUN Computer Science courses on this area: COMP 2003: Computer Architecture COMP 3731: Introduction to Scientific Computing COMP 4734: Matrix Computations and Applications MUN Computer Science professors teaching courses / doing research in in this area: Sharene Bungay Rod Byrne Ashoke Deb Paul Gillard (Retired) George Miminis