Lesson Objectives Aims

Slides:



Advertisements
Similar presentations
Base 10 Denary Decimal
Advertisements

Boolean Algebra. Starter Task State 5 basic data types together with one operation that can be performed on each. We have looked at 4 in the past few.
A-Level Computing#BristolMet Session Objectives#8 express numbers in binary, octal and hexadecimal explain the use of code to represent a character set.
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
Information Processing Session 5B Binary Arithmetic Slide
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
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.
Binary Aim: Explain binary and binary units Objective 1: Convert positive denary whole numbers (0-255) into 8-bit binary numbers and vice versa Objective.
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
Computer Systems 1 Fundamentals of Computing
Numbering Systems Decimal (Denary) base 10. Clumsy when dealing with computers. Other systems –Binary –Octal –Hexadecimal Convenient when dealing with.
Simple Data Type Representation and conversion of numbers
Numbering systems.
Computer System & Binary Review. Memory Model What memory is supposed to look like.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Candidates should be able to:
BINARY Toby Wilson. LEARNING OBJECTIVES  Be able to convert binary to denary  Be able to convert denary into binary  Be able to explain how computers.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
Binary a. express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal;
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Binary Numbers. Base 10 and Base 2  We normally work with numbers in base 10.  In base 10 we use the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.  Everything.
Understanding Binary Understanding Computers. Understanding Computers L3 – Understanding Binary Learning Objectives All will Understand why all data is.
3.1 Denary, Binary and Hexadecimal Number Systems We use the denary (base 10) number system in our daily life for counting and calculation. Computers use.
© OCR 2016 Unit 2.6 Data Representation Lesson 1 ‒ Numbers.
Lesson Objectives Aims You should know about: Binary numbers ‘n’ that.
Binary & Hex Review.
Unit 2.6 Data Representation Lesson 1 ‒ Numbers
Understanding binary Understanding Computers.
Binary, Denary, Hexadecimal Conversion Binary Addition
Lec 3: Data Representation
Lesson Objectives Aims You should be able to:
Data Representation.
Data Representation – numbers Binary conversion Hexadecimal Negative numbers Binary addition Binary shifts.
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 : INTRODUCTION
Memory Parts of a computer
What is Binary? Binary is a two-digit (Base-2) numerical system, which computers use to process and store data. The reason computers use the binary system.
Unit 2.6 Data Representation Lesson 1 ‒ Numbers
Denary to Binary Numbers & Binary to Denary
…to GCSE Level with Python Sue Sentance
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
Chapter 3 – Digital Logic and Binary Numbers
University of Gujrat Department of Computer Science
Lesson Objectives Aims You should be able to: Convert Denary to Binary
Data Representation Numbers
Topic 3: Data Binary Arithmetic.
Representation of Data in Computer Systems
Fundamentals of Data Representation
Data Representation Conversion 05/12/2018.
Data Representation – Numbers
Information Representation
(return of the…) Data blast
C1 Number systems.
Storing Negative Integers
Homework Homework Continue Reading K&R Chapter 2 Questions?
A-level Computer Science
Binary System.
23/04/2019 Data Representation Conversion.
Binary & Hex Review.
Data Binary Arithmetic.
WJEC GCSE Computer Science
Computer Systems Nat 4/5 Computing Science Data Representation
UNIT – 3 & 4. Data Representation and Internal
Two’s Complement & Binary Arithmetic
Section 6 Primitive Data Types
Presentation transcript:

Lesson Objectives Aims Be able to identify and use primitive data types such as Integer, real, character, string and Boolean Represent positive integers in binary Use sign and magnitude or twos compliment to represent negative binary numbers Be able to perform addition and subtraction in binary (integers) Represent positive integers as Hexadecimal Convert integers between Binary, Hex and Denary

If you don’t know these by now you: Primitive data types If you don’t know these by now you: Haven’t done your homework Haven’t been completing programming tasks Can’t program…

Create a table with the following headings and fill it in, without using the internet or a book: Data Type Description Example Integer Real/Float Character String Boolean

Binary Quantities The smallest piece of information a computer can understand is a 1 or a 0 This single digit is called a BIT. Obviously, this isn’t too useful on its own. If we group 4 BITS together, we have 16 possible combinations – a NYBBLE

1 or 0 = Bit 4 bits = Nybble 8 bits = Byte (most common grouping) 1024 bits = 1 Kilobyte (Kb) (2^10) 1024Kb = 1 Megabyte (Mb) (2^20) 1024Mb = 1 Gigabyte (Gb) (2^30) 1024Gb = 1 Terabyte (Tb) (2^40) 1024Tb = 1 Petabyte (Pb) (2^50) All are powers of 2

Denary We count in a number system called Denary It is a BASE 10 number system because… There are 10 digits! 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (if you were wondering)

Number systems Think about what happens when we count… Eventually we run out of digits What happens at 9? What REALLY does this mean? What does it tell you about the PLACE each number has?

What does the Denary number 1654 mean? Number systems What does the Denary number 1654 mean? 1654 = 1x1000 + 6x100 + 5x10 + 4x1 Thousands (x1000) Hundreds (x100) Tens (x10) Units (x1) 1 6 5 4

It’s all about the BASE. Geddit? See what I did there? So now we should understand the following ideas: The BASE of our number system is given by the number of digits we have available The PLACE of a digit denotes its value The place value is determined by multiplying the previous column value by the base of the number system It’s all about the BASE. Geddit? See what I did there?

Number systems used in CS Base Binary 2 Octal 8 Denary 10 Hexadecimal 16

Hex, Binary and Denary A useful table…

Binary Binary has only 2 digits 128 64 32 16 8 4 2 1 Binary has only 2 digits Which is why we have the place/column values shown above If we take a Byte of data, we can store numbers up to 255 Or 256 different COMBINATIONS of numbers (including zero)

Hexadecimal Binary numbers can quickly become long and cumbersome This makes them difficult for us to understand Think about how easy it would be to make an error copying a number such as 11010101100011100001111001010101

Hexadecimal allows us to shorten these numbers significantly. Hexadecimal is base 16 There are 16 digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

Each column is now worth 16x the previous: = 4096*1 + 256*5 + 16*15 + 1*8 = 4096 + 1280 + 240 + 8 = 5624 4096 256 16 1 5 F 8

Denary (Decimal) to binary Convert 187 to Binary Write out your table (just keep doubling each number from 1) Working from LEFT to RIGHT, put a 1 under each number that is nearest to your remaining total 187 – 128 = 59 59 – 32 = 27 27 – 16 = 11 11 – 8 = 3 3 – 2 = 1 1-1 = 0 187 = 10111011 128 64 32 16 8 4 2 1

Denary (Decimal) to Hex First convert to Binary 187 = 10111011 Then split in to two Nybbles 1011 1011 Convert Nybbles to Hex 1011 = 11 = B in Hex 187 = BB 128 64 32 16 8 4 2 1

Hex to Binary Take each hex digit F8 Turn each in to a 4 bit Nybble F = 1111, 8 = 1000 Combine: 11111000

Hex to Decimal (Denary) Convert to Binary first! Then convert from Binary to Decimal F8 = 11111000 11111000 = 128 + 64 + 32 + 16 + 8 = 248

Addition and Subtraction Addition is eeeeeaasssssyyyyy Repeat after me: Which truth table is this…? Sum Equals 0 + 0 0 + 1 1 1 + 0 1 + 1 0… er?

Now do some sums.. Sum Equals 0 + 0 0 + 1 1 1 + 0 1 + 1 0 CARRY 1 1 + 1 + 1 1 CARRY 1 01101100 + 00111111 00111111 + 00010101 + 10101010

Subtraction Sum Equals 0 - 0 1 - 0 1 1 - 1 0 – 1 = 10 - 1 1 - 0 1 1 - 1 0 – 1 = 10 - 1 01 (borrowing from the next column IF it’s 1) 0 – 1 if the column next doesn’t contain a 1?! PANIC!!!! 11 – 1

Worked Examples 1 – 1 = 0 0 – 0 = 0 1 – 0 = 1 Answer - 1000 - 1011 0011 1 – 1 = 0 0 – 0 = 0 1 – 0 = 1 Answer - 1000

10 - 5 1010 - 0101 1010 0101 ---- 01 1010 0101 ----

10 - 7 1010 - 0111 1010 0111 ---- 1 1 0000 0111 ---- 1 11 0000 0111 ---- 1 11 0000 0111 ---- 0011

11111111 - 00001111 00111011 - 00101011 00100010 - 00101011 01000000 - 00001111

But… what about negative numbers?? There has to be a way? Yes, but it’s a compromise which reduces the maximum size of a number that can be stored in a byte.

The simplest system is sign and magnitude Normal binary number (150): 128 64 32 16 8 4 2 1 Sign Magnitude 64 32 16 8 4 2 1

Magnitude = the size of the actual number Sign bit = 0 or 1 1 = negative 0 = positive Magnitude = the size of the actual number

Two’s Compliment Sets the sign bit to be negative (like in sign and magnitude) But it’s not a flag – it means the negative value of its column So in 8 bit numbers, -128

Two’s compliment conversion To represent the number -13 as an 8-bit binary number... Step 1 : Convert the positive number 13 into an 8-bit binary integer: 128 64 32 16 8 4 2 1 Step 2 : Change all the bits from 0 to 1 (or from 1 to 0.) 128 64 32 16 8 4 2 1 Step 3 : Add 1 - Perform a binary calculation. 1   +

The column values are now slightly different. What negative number is this? Flip the bits and add 1! Or -128+32+16+8+2+1 - 128 64 32 16 8 4 2 1

Subtraction with 2’s compliment 10 – 4… 10 = 00001010 4 = 00000100 Convert the number to subtract (4) in to two’s compliment: 11111100 Now add… 00001010 -------- 100000110 The 1 has overflowed (consider it dead…) what’s left is the correct answer.

Lesson Objectives Aims Key Words I. Perform bitwise manipulation and use masks with AND, OR and XOR J. Understand the use of character sets (ASCII and Unicode) to represent text Key Words

Processors will have the ability to perform “shift” operations Logical Operators Processors will have the ability to perform “shift” operations There are two types: Logical Arithmetic They both have similar effects but are subtly different

Why - Quick arithmetic! Shifting bits RIGHT will DIVIDE the number by 2 Shifting bits LEFT will MULTIPLY the number by 2

Operators You MUST be already familiar with: NOT AND OR XOR

Not – inverse, 1’s compliment AND – Find the status of a bit OR – Reset/Change values XOR – find matching bits Any byte/register size operations with these are called “masks” or “bitwise manipulation” E.g. 00011001 AND 00000001 (mask) 00000001

ASCII – 127 characters (8 bits, 1 parity) Unicode – 16 bits, now more ASCII and Unicode ASCII – 127 characters (8 bits, 1 parity) Unicode – 16 bits, now more Enables all languages to be stored World wide standard Should display on any device/OS/Compliant software

Review/Success Criteria