COMP 102: Computers and Computing

Similar documents
[301] Bits and Memory. Tyler Caraza-Harter

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

Discussion. Why do we use Base 10?

Worksheet - Storing Data

Bits, bytes and digital information. Lecture 2 COMPSCI111/111G

Information and Creative Technology

CSC 101: Lab Manual#9 Machine Language and the CPU (largely based on the work of Prof. William Turkett) Lab due date: 5:00pm, day after lab session

COMP 102: Computers and Computing

Data Representation 1

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Example 1: Denary = 1. Answer: Binary = (1 * 1) = 1. Example 2: Denary = 3. Answer: Binary = (1 * 1) + (2 * 1) = 3

ITP 140 Mobile App Technologies. Colors

Lecture 1: What is a computer?

Objectives. Connecting with Computer Science 2

Binary representation and data

CS 101 Representing Information. Lecture 5

Introduction to Computer Science (I1100) Data Storage

ETGG1801 Game Programming Foundations I Andrew Holbrook Fall Lecture 0 - Introduction to Computers 1

Variables and Data Representation

Basic data types. Building blocks of computation

Chapter 7. Representing Information Digitally

umber Systems bit nibble byte word binary decimal

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

Technology in Action

8/31/2015 BITS BYTES AND FILES. What is a bit. Representing a number. Technically, it s a change of voltage

Final Labs and Tutors

Intermediate Programming & Design (C++) Notation

History of Computing. Ahmed Sallam 11/28/2014 1

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

COSC 243 (Computer Architecture)

FA269 - DIGITAL MEDIA AND CULTURE

Unit 2 Digital Information. Chapter 1 Study Guide

计算机信息表达. Information Representation 刘志磊天津大学智能与计算学部

(Refer Slide Time: 00:23)

Lecture 3: Truth Tables and Logic Gates. Instructor: Joelle Pineau Class web page:

COSC 122 Computer Fluency. Computer Organization. Dr. Ramon Lawrence University of British Columbia Okanagan

REPRESENTING INFORMATION:

An Overview of the Computer System. Kafui A. Prebbie 24

Computer Memory Basic Concepts. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

Using sticks to count was a great idea for its time. And using symbols instead of real sticks was much better.

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

Topic Notes: Bits and Bytes and Numbers

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

Chapter 9: A Closer Look at System Hardware

Topic Notes: Bits and Bytes and Numbers

Chapter 9: A Closer Look at System Hardware 4

Colour and Number Representation. From Hex to Binary and Back. Colour and Number Representation. Colour and Number Representation

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

Memory Addressing, Binary, and Hexadecimal Review

Agenda EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 1: Introduction. Go over the syllabus 3/31/2010

COMP 102: Computers and Computing

Software and Hardware

Data Storage. Slides derived from those available on the web site of the book: Computer Science: An Overview, 11 th Edition, by J.

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

Technical concepts. Some basics of computers today. Comp 399

St. Benedict s High School. Computing Science. Software Design & Development. (Part 2 Computer Architecture) National 5

National 5 Computing Science Software Design & Development

HARDWARE AND OPERATING SYSTEMS

Bits. Binary Digits. 0 or 1

Analogue vs. Discrete data

v.m.g.rajasekaran ramani sri sarada sakthi mat. Hr. sec. school

Lecture #3: Digital Music and Sound

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Electronic Data and Instructions

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

HW 1. Due: Wed Sep. 27. CS105: Great Insights in Computer Science Michael L. Littman, Fall Rules

Unit - II. Computer Concepts and C Programming 06CCP13. Unit II

What's in a computer?

Representing the Real World

E40M. Binary Numbers, Codes. M. Horowitz, J. Plummer, R. Howe 1

Parts are adapted from Windows 98 by Mark Twain Media, Inc. A Computer System has Hardware and Software

Data Representation. Interpreting bits to give them meaning. Part 1: Numbers, Bases, and Binary

2nd Paragraph should make a point (could be an advantage or disadvantage) and explain the point fully giving an example where necessary.

Administrative Notes February 9, 2017

CPS122 Lecture: From Python to Java

Lecture C1 Data Representation. Computing and Art : Nature, Power, and Limits CC 3.12: Fall 2007

CMSC 104 -Lecture 2 John Y. Park, adapted by C Grasso

Experimental Methods I

Bits and Bit Patterns

C H A P T E R 1. Introduction to Computers and Programming

Physics 331 Introduction to Numerical Techniques in Physics

Digital Computers and Machine Representation of Data

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

2/15/2008. Announcements. Programming. Instruction Execution Engines. Following Instructions. Instruction Execution Engines. Anatomy of a Computer

Introduction To Computer Hardware

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

Digital Media. Daniel Fuller ITEC 2110

COMP 102: Computers and Computing Lecture 1: Introduction!

CMPS 10 Introduction to Computer Science Lecture Notes

Programming Concepts and Skills. ASCII and other codes

Data Representation From 0s and 1s to images CPSC 101

Computer Systems. Binary Representation. Binary Representation. Logical Computation: Boolean Algebra

Chapter 1. Data Storage Pearson Addison-Wesley. All rights reserved

Logic, Words, and Integers

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

Chapter 2 Bits, Data Types, and Operations

INTRODUCTION TO COMPUTERS

Data Representation. Types of data: Numbers Text Audio Images & Graphics Video

Transcription:

COMP 102: Computers and Computing Lecture 2: Bits&bytes, Switches, and Boolean Logic Instructor: Kaleem Siddiqi (siddiqi@cim.mcgill.ca) Class web page: www.cim.mcgill.ca/~siddiqi/102.html

The Lowly Bit What is the smallest unit of information? Chemistry has its molecules. Physics has its strings. Computer science has its bits: True / False On / Off 1 / 0 Think of it as a switch: 2

Recall The vacuum tube: The transistor: These are electronic on/off switches. The difference engine used mechanical on/off switches (think lever ). 3

What s a Bit? Word Bit is a contraction of Binary digit What s a binary digit? Base 10: In decimal number system, a digit can be any of the ten values 0,, 9 Base 2: In binary number system, a digit can be any of the two values 0, 1 Bits are nice because they are: Simple: There s no smaller discrete distinction to be made. Powerful: Sequences of bits can represent seemingly anything. 4

Representing numbers 102 100s 10s 1s Decimal System uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 10 Place-value number system: position of a digit interpreted to give the value 5

Representing numbers: Decimal system 102 = 1 x 100 + 0 x 10 + 2 x 1 = 1 x 10 2 + 0 x 10 1 + 2 x 10 0 1 decimal digit produces 10 distinct values 2 decimal digits produce 100 distinct values 3 decimal digits produce 1000 distinct values n decimal digits produce 10 n distinct values 6

Representing numbers: Binary system 1100110??????? Binary System uses 2 digits: 0, 1 Base 2 7

Representing numbers: Binary system 1100110 64s 32s 16s 8s 4s 2s 1s Binary System uses 2 digits: 0, 1 Base 2 8

Representing numbers: Binary system 1,100,110 2 = 1 x 64 + 1 x 32 + 0 x 16 + 0 x 8 + 1 x 4 + 1 x 2 + 0 x 1 = 1 x 2 6 + 1 x 2 5 + 0 x 2 4 + 0 x 2 3 + 1 x 2 2 + 1 x 2 1 + 0 x 2 0 1 binary digit produces 2 distinct values 2 binary digits produce 4 distinct values 3 binary digits produce 8 distinct values n binary digits produce 2 n distinct values 9

Representing numbers: Arbitrary Base 23641 7 =? 85342 9 =? In general, use positional notation: A number a n a n-1 a n-2 a 0 in base b has the value a n *b n + a n-1 *b n-1 + + a 0 *b 0 10

Converting from Base 10 to Base 2 136 10 =? 2 Keep dividing by 2 and storing the remainder: 136/2 = 68, R = 0 68/2 = 34, R = 0 34/2 = 17, R = 0 17/2 = 8, R = 1 8/2 = 4, R = 0 4/2 = 2, R = 0 2/2 = 1, R = 0 1/2 = 0, R = 1 Answer: 10001000 2 11

Binary Numbers in Computing Easy to make fast, reliable, small devices that have only 2 states 1/0 represented by hole/no hole in punched card hi/low voltage (memory chips) light bounces off/light doesn t bounce off (CDs/DVDs) magnetic charge present/no magnetic charge (disks) 12

Measuring Data We can group number of binary digits and refer to the group sizes by special names: 1 bit(b) = 2 1 = represents 2 different values 1 byte(b) = 8 bits = 2 8 = 256 values 1 kilobyte(kb) = 1024 bytes = 2 10 bytes 1 megabyte(mb) = 1024 KB = 2 20 bytes 1 gigabyte(gb) = 1024 MB = 2 30 bytes 1 terabyte(tb) = 1024 GB = 2 40 bytes 13

Combining bits to represent complex information Remember bit can only be 0 or 1. We can combine multiple bits to represent more complex data. Text Images Sound Video Etc. 14

Representing Text Each character is encoded using 1 byte ASCII (American Standard Code for Information Interchange) table Space: 15

Representing Text M A R C 16

Almost everything can be represented with bits Escher s drawing: Use one bit to represent the colour (black=0, white=1) at each particular image location. 17

Almost everything can be represented with bits Digital images: A group of bits represents the colour at each particular image location: we call this a pixel. An image pixel is one of Red, Blue or Green. How do we encode this information with bits? How many bits do we need? 18

Almost everything can be represented with bits Digital sound: Average sound intensity (= a number) over a short time interval is represented using a group of bits. 19

Modern technologies need lots of bits! Consider the ipod: 60Gb. 1Gb = one billion bytes (1 byte = 8 bits). Sound: 128Kbps per second of sound (Kbps = kilobits). So 62,500 minutes of sound, or 15,000 songs (at 4min. per song). Screen: 320x240(=76,800) pixels. Each pixel needs 1 byte of RGB (=Red-Blue-Green) intensity. At 30 frames per second, that s 55.3 million bits per second. So 144 minutes of (quiet) video. 20

Logical variable Bits are not just for sound and images. Bits can store logical variables. A logical variable is something that we can imagine as being True or False. TodayIsThursday = True ItIsDarkOutside = False IAmTeachingCOMP102 = True TodayIsThursday, ItIsDarkOutside and IAmTeachingCOMP102 are logical variables. They can be True or False. Logical variables are also sometimes called Boolean variables. 21

And, Or, Not Logical variables can be combined with logical operations. The most important logical operations are AND, OR, and NOT. 1. x AND y is True only if both x is True and y is True. 2. x OR y is True if either x or y are True. 3. NOT x is True only if x is False. Logical operations have the intuitive English meaning. 22

Logical expressions Logical expressions combine logical variables and logical operations into more complex expressions. IAmTeachingCOMP102 AND ItIsDarkOutside = False NOT ItIsDarkOutside = True IAmTeachingCOMP102 OR TodayIsThursday = True ( TodayIsThursday OR IAmTeachingCOMP102 ) AND ( IAmTeachingCOMP102 AND ( NOT ItIsDarkOutside ) ) =?? 23

Implementing logic How do we implement a logical variable? Easy! One switch per logical variable electrons in electrons out? Closed switch = True electrons in electrons out? Open switch = False How do we implement logical operations? How do we implement logical expressions? 24

Implementing logical operations Key Idea: Combining switches AND operation: Combine switches in series x y (x = True) AND (y = True) = True x y (x = True) AND (y = False) = False 25

Implementing logical operations OR operation: Combine switches in parallel x (x = True) OR (y = True) = True y x (x = True) OR (y = False) = True y NOT operation is slightly more complicated. 26

Implementing logical expressions Combine multiple switches. E.g. ( TodayIsThursday OR IAmTeachingCOMP102 ) AND ( IAmTeachingCOMP102 AND ( NOT ItIsDarkOutside ) ) =?? 27

Practice example Three friends are trying to decide what to do Saturday night (see a movie or go out clubbing). They settle the issue by a vote (everyone gets a single vote, the activity with the most votes wins.) Assume you want a computer to automatically compile the votes and declare the winning activity. What logical variables would you use? Can you write a logical expression, which evaluates whether or not you will go Clubbing (True = Clubbing, False = Movie)? 28

Take-home message Understand the concept of a bit. Know how to combine multiple bits to represent complex information (text, images, sound, video). Understand what are logical variables. Know the three basic logical operations. Be able to evaluate logical expressions. 29

Final comments Some material from these slides was taken from: http://www.cs.rutgers.edu/~mlittman/courses/cs442-06/ http://cim.mcgill.ca/~sveta/comp102/ 30