Introduction to Binary

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

KFUPM COE 202: Digital Logic Design Number Systems Part 3 Courtesy of Dr. Ahmad Almulhem.
1 Lecture-2 CSIT-120 Spring 2001 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
How Computers Represent Numbers Friday, Week 5. Binary Code A series of 1’s and 0’s Place value is in powers of 2.
How Computers Represent Numbers Friday, Week 5. Binary Code A series of 1’s and 0’s Place value is in powers of 2.
Digital Circuit Why Digital Circuit? – Digital signals ( 0 and 1) are very easy to handle with electronic circuits only 2 states needed: Switch ON or OFF,
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
28-Jun-15 Number Systems. 2 Bits and bytes A bit is a single two-valued quantity: yes or no, true or false, on or off, high or low, good or bad One bit.
Binary Conversion In today’s lesson we will link together the binary and algorithm topics by looking at how to get the computer to: convert binary to decimal.
The Binary Number System 6 th grade math. What is binary? The number system we use is decimal, based on the number 10 The binary system is instead based.
Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.
Hexadecimal and ASCII Lesson Objective: Understand the purpose of ASCII and how to use it. Lesson Outcome: Convert between Hexadecimal and ASCII Convert.
1 Survey of Computer Science CSCI 110, Spring 2011 Lecture 16 Digital Circuits, binary Numbers.
CMPT 120 How computers run programs Summer 2012 Instructor: Hassan Khosravi.
Representing Information Digitally. Digitization Initially transforming data for computer use Assigning people social security numbers The creation of.
How Computers Work Dr. John P. Abraham Professor UTPA.
Lecture 11: Machine Processing Intro to IT COSC1078 Introduction to Information Technology Lecture 11 Machine Processing James Harland
Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.
Binary Arithmetic & Data representation
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Hardware Data Storage.
How Computers Work … and how you can work them. Art 315 Lecture 03 Dr. J Parker Fall 2010.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Computer Science Binary. Binary Code Remember the power supply that is inside your computer and how it sends electricity to all of the components? That.
THE BINARY SYSTEM.
Visualizing Decimal and Binary
THE BINARY NUMBER SYSTEM “There are only 10 types of people in this world: Those who understand BINARY and those who do not.”
1 Ethics of Computing MONT 113G, Spring 2012 Session 1 Digital Circuits, binary Numbers Course webpage:
Georgia Institute of Technology Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology May 2006.
Binary 101 Gads Hill School. Aim To strengthen understanding of how computers use the binary number system to store information.
Introduction to Digital Electronics Lecture 2: Number Systems.
HNC COMPUTING - COMPUTER PLATFORMS 1 Micro Teach Binary.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
Lesson 6 Binary Understand what Binary Code means and apply this knowledge Understand how data is represented using bit systems and be able to change decimal.
Understanding Computers
Binary a. express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal;
Number systems Visualizing Decimal and Binary. We count in base 10 because people started by counting on their fingers Base 10 is a number system that.
Understanding Binary Understanding Computers. Understanding Computers L3 – Understanding Binary Learning Objectives All will Understand why all data is.
Binary and Hard Disk PEOPLE Program
Understanding binary Understanding Computers.
The Art of Computational Thinking…Binary Code
Unit 18: Computational Thinking
Lesson Objectives Aims
CSCI 198: Lecture 4: Data Representation
BINARY CODE.
Storage Hardware This icon indicates the slide contains activities created in Flash. These activities are not editable. For more detailed instructions,
CSCI 161: Lecture 4: Data Representation
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
Binary numbers pt. 2.
Counting by 10s, 100s, 1000s Five-digit
Introduction to Programming Part 3
Visualizing Decimal and Binary
Binary Arithmetic.
Coding Schemes and Number Systems
Data Representation Conversion 05/12/2018.
Fundamentals of Data Representation
CS 101 – Sept. 4 Number representation Integer Unsigned √ Signed √
Introduction to Programming Part 2
COMS 161 Introduction to Computing
How Computers Store Data
Introduction to Programming Part 3
Learning Intention I will learn how computers store text.
Abstraction – Number Systems and Data Representation
ECE 331 – Digital System Design
Binary CSCE 101.
Number Systems Today, I’ll be giving an introduction to:
Lecture 36 – Unit 6 – Under the Hood Binary Encoding – Part 2
Digital Representation of Data
Section 6 Primitive Data Types
Presentation transcript:

Introduction to Binary

Why Bother with Binary? This is all about electronics We don’t use binary because electronics do We designed electronics to use binary because it is very easy to do so Trying to use decimal inside electronics would be crazy difficult

Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything https://en.wikipedia.org/wiki/Pi https://en.wikipedia.org/wiki/To_be,_or_not_to_be

Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers!

Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers! π = 3.1415926535 [and more!] https://en.wikipedia.org/wiki/Pi

Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers! π = 3.1415926535 [and more!] Words “To be, or not to be!” Pictures Videos https://en.wikipedia.org/wiki/To_be,_or_not_to_be

Why Bother with Binary? Operations are easy in electronics (just wait!) Binary numbers can be used to represent anything Numbers! π = 3.1415926535 [and more!] Words “To be, or not to be!” Pictures Videos Programs (like games!)

Number Systems Ways to organize and write numbers Set of digits Set of operations Addition Subtraction https://en.wikipedia.org/wiki/Numeral_system

Number Systems – Decimal Digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Operations Addition ( 3 + 5 ) Subtraction ( 5 – 3 ) https://en.wikipedia.org/wiki/Decimal

Number Systems – Decimal Written Form Every “place” is 10 times the place to the right Number 1000 100 10 1 17 7 51 5 5281 2 8

Number Systems – Decimal What’s going on, here? 1000 * 5 + 100 * 2 + 10 * 8 + 1 * 1 = 5281 Number 1000 100 10 1 5281 5 2 8

Number Systems – Binary Digits 0, 1 Operations Addition ( 011 + 101 ) Subtraction ( 101 – 011 ) Fun new things (and, or, not, xor) https://en.wikipedia.org/wiki/Binary_number

Number Systems – Binary States can be easily represented in electronics Off False On True 1

Number System - Binary Written Form Every “place” is twice the place to the right Number 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 17 51 5281

Number Systems – Binary Same number as before 1000000000000 + 0010000000000 + 0000010000000 + 0000000100000 + 0000000000001 = 1010010100001 Number 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 5280

Familiar Numbers Decimal: 25 Binary: 11001 10 * 2 + 1 * 5 25 10000 + 01000 + 00001 11001 Number 1000 100 10 1 25 2 5 Number 128 64 32 16 8 4 2 1 11001

Converting to Binary Decimal 128 64 32 16 8 4 2 1 Binary 29 00011101 00011101 31 33 100 111 125

Binary Numbers Just another way to “write” the numbers you see every day

Numbers with Meaning How do we represent words in computers?

Numbers with Meaning How do we represent words in computers? Numbers!

Numbers with Meaning How do we represent words in computers? Numbers! (Bet you didn’t see what one coming...)

ASCII American Standard Code for Information Interchange A special set of numbers to represent letters All letters have a number assigned to them https://en.wikipedia.org/wiki/ASCII

ASCII □■□□□□□■ □■□□■■■■ □■□□□□■□ P 80 □■□■□□□□ □■□□□□■■ □■□■□□□■ Letter Decimal Binary Pattern A 65 01000001 □■□□□□□■ O 79 01001111 □■□□■■■■ B 66 01000010 □■□□□□■□ P 80 01010000 □■□■□□□□ C 67 01000011 □■□□□□■■ Q 81 01010001 □■□■□□□■ D 68 01000100 □■□□□■□□ R 82 01010010 □■□■□□■□ E 69 01000101 □■□□□■□■ S 83 01010011 □■□■□□■■ F 70 01000110 □■□□□■■□ T 84 01010100 □■□■□■□□ G 71 01000111 □■□□□■■■ U 85 01010101 □■□■□■□■ H 72 01001000 □■□□■□□□ V 86 01010110 □■□■□■■□ I 73 01001001 □■□□■□□■ W 87 01010111 □■□■□■■■ J 74 01001010 □■□□■□■□ X 88 01011000 □■□■■□□□ K 75 01001011 □■□□■□■■ Y 89 01011001 □■□■■□□■ L 76 01001100 □■□□■■□□ Z 90 01011010 □■□■■□■□ M 77 01001101 □■□□■■□■ ! 33 00100001 □□■□□□□■ N 78 01001110 □■□□■■■□ ? 63 00011111 □□□■■■■■ Letter Decimal Binary Pattern A 65 01000001 □■□□□□□□■ B 66 01000010 C 67 01000011 D 68 01000100 E 69 01000101 F 70 01000110 G 71 01000111 H 72 01001000 I 73 01001001 J 74 01001010 K 75 01001011 L 76 01001100 M 77 01001101 N 78 01001110 O 79 01001111

Making Words From Letters How do we write our ABCs?

Making Words From Letters How do we write our ABCs? Like this: □■□□□□□■□■□□□□■□□■□□□□■■

Making Words From Letters How do we write our ABCs? Like this: □■□□□□□■□■□□□□■□□■□□□□■■ How about XYZ?

Making Words From Letters How do we write our ABCs? Like this: □■□□□□□■□■□□□□■□□■□□□□■■ How about XYZ? □■□■■□□□□■□■■□□■□■□■■□■□

Can You Write Your Initials? Letter Decimal Binary Pattern A 65 01000001 □■□□□□□■ O 79 01001111 □■□□■■■■ B 66 01000010 □■□□□□■□ P 80 01010000 □■□■□□□□ C 67 01000011 □■□□□□■■ Q 81 01010001 □■□■□□□■ D 68 01000100 □■□□□■□□ R 82 01010010 □■□■□□■□ E 69 01000101 □■□□□■□■ S 83 01010011 □■□■□□■■ F 70 01000110 □■□□□■■□ T 84 01010100 □■□■□■□□ G 71 01000111 □■□□□■■■ U 85 01010101 □■□■□■□■ H 72 01001000 □■□□■□□□ V 86 01010110 □■□■□■■□ I 73 01001001 □■□□■□□■ W 87 01010111 □■□■□■■■ J 74 01001010 □■□□■□■□ X 88 01011000 □■□■■□□□ K 75 01001011 □■□□■□■■ Y 89 01011001 □■□■■□□■ L 76 01001100 □■□□■■□□ Z 90 01011010 □■□■■□■□ M 77 01001101 □■□□■■□■ ! 33 00100001 □□■□□□□■ N 78 01001110 □■□□■■■□ ? 63 00011111 □□□■■■■■

Bonus Can you decode the binary code on my shirt?

Arithmetic in Binary Easy You only need to know how to add 0 and 1 Hardest operation you ever have to do is 1 + 1 Hint: the answer isn’t “2”

Addition – Decimal 2 + 2 = 2 + 8 = 7 + 8 =

Addition – Binary 0 + 0 = 0 + 1 = 1 + 0 = 1 + 1 =

Addition – Binary 10 + 10 = ( 2 + 2 ) 10 + 1000 = ( 2 + 8 ) 10 + 10 = ( 2 + 2 ) 10 + 1000 = ( 2 + 8 ) 111 + 1000 = ( 7 + 8 ) 10110 + 01011 = ( 22 + 11 )

Funny Operators And 0 ∧ 0 = 0 0 ∧ 1 = 0 1 ∧ 0 = 0 1 ∧ 1 = 1 Or

Programs in Binary Everything in a computer is represented with binary numbers Programs in a computer are (of course!) represented in binary numbers

Programs in Binary Instructions Program Storage List of things you can do Program List of instructions, in order Storage Instructions, encoded into binary, in the computer’s memory

Programs in Binary - Instructions Human Robots Just like our first week in Coding Club Can move forward Can turn right Can turn left

Programs in Binary Program Move forward Turn left Turn right etc.

Programs in Binary Instructions .. in binary! We have 3 instructions We will need two “bits” for each instruction 2 bits can represent 0, 1, 2, or 3 in decimal We only need 3 of these 4; one of them will be unused

Programs in Binary Instructions .. in binary! Turn left: 01 Turn right: 10 Move forward: 11

Programs in Binary Program Instructions Move forward Turn left Turn right etc. Instructions 11 01 10 etc.

Programs in Binary Program in computer memory 111101111011 or ■■■■□■■■■□■■

How Does a Computer Run a Program? Program is in memory ■■■■□■■■■□■■ Computer knows all instructions are 2-bits wide Computer starts at the beginning Read 2 bits Decide which instruction is represented Perform instruction (e.g. turn, move) Repeat

Complicated Programs Human Robots Real Computer Programs Limited to turn, move Real Computer Programs Can do much more

Complicated Programs Perform arithmetic Make decisions Run loops Load/store information

Complicated Programs Require lots of instructions Examples: load, store add, subtract compare jump!

Complicated Programs Instructions Instructions Load Add Jump Jump-if-equal Instructions 0001 0011 0101 0110

Complicated Programs Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra What? Where? What/Where ?

Let’s Count to Ten Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010

Let’s Count to Ten Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 0001 0000 0011 0001 0110 1010 0101 0101 0101

Let’s Count to Ten Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 0001 0000 0011 0001 0110 1010 0101 0101 0101 code code code code

Let’s Count to Ten Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 0001 0000 0011 0001 0110 1010 0101 0101 0101 data data data data data

Complicated Programs Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 0001 0000 0011 0001 0110 1010 0101 0101 0101 data data data data data ?

} Complicated Programs Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 } 0001 0000 0011 0001 0110 1010 0101 0101 0101 data data data data data

} { Complicated Programs Instructions Instructions Extra Load Add Jump Jump-if- equal Instructions 0001 0011 0101 0110 Extra 0000 0001 0101 1010 } 0001 0000 0011 0001 0110 1010 0101 0101 0101 code data code data code data data code data {