Section 6 Primitive Data Types

Slides:



Advertisements
Similar presentations
Candidates should be able to:
Advertisements

 A binary number is a number that includes only ones and zeroes.  The number could be of any length  The following are all examples of binary numbers.
Computer Number Systems This presentation will show conversions between binary, decimal, and hexadecimal numbers.
Hexadecimal and ASCII Lesson Objective: Understand the purpose of ASCII and how to use it. Lesson Outcome: Convert between Hexadecimal and ASCII Convert.
Storing data Getting data out Data types Ruby as a foundation Program Variables Click icon to hear comments (the download may take a minute)
Binary and Hexadecimal Numbers
Computers Organization & Assembly Language
Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.
Information and Programs. Foundations of Computing Information –Binary numbers –Integers and Floating Point –Booleans (True, False) –Characters –Variables.
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Binary Arithmetic In today’s lesson we will look at: a reminder of how binary works adding binary numbers overflow complements negative numbers and subtraction.
The Teacher CP4 Binary and all that… CP4 Revision.
Number systems, Operations, and Codes
The Teacher CP4 Binary and all that… CP4 Revision.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Data Representation, Number Systems and Base Conversions
Candidates should be able to:
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
Computer Studies Today Chapter 19 1 Chapter 19. Computer Studies Today Chapter 19 2 »Information stored in a computer is in two states: –ON –OFF.
The Hexadecimal Number System Representation of Data in Computer Systems.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
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.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Coding Part 2. Weight of the Digit 3672 Thousands (10 3 )Hundreds (10 2 )Tens (10 1 )Units (1) = Weights Decimal Example (3672) 10 Binary.
COMPUTER ORGANIZATION 4 TH LECTURE. ASCII Code  ASCII ( American Standard Code for Information Interchange).  Input and output devices that communicate.
WHAT IS BINARY? Binary is a number system that only uses two digits: 1 and 0. Any information that processed by a computer it is put into sequence of.
Nat 4/5 Computing Science Lesson 1: Binary
Objectives Today: P4 Data Types – Floating Points P4 Variable Quiz P3 Iteration and Selection Practical Are you logged on? Then come around the table Unit.
Data Representation COE 308 Computer Architecture
Computer Science 210 Computer Organization
Programming and Data Structure
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
3.1 Denary, Binary and Hexadecimal Number Systems
Recap Add these numbers together in binary
Data Representation Binary Numbers Binary Addition
Lesson Objectives Aims
Integer Real Numbers Character Boolean Memory Address CPU Data Types
EPSII 59:006 Spring 2004.
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
Lesson Objectives Aims You should be able to: Convert Denary to Binary
Data Structures Mohammed Thajeel To the second year students
Data Representation COE 301 Computer Organization
Chapter 2 Bits, Data Types & Operations Integer Representation
Introduction to Java, and DrJava part 1
Data Representation Conversion 05/12/2018.
Computer Science 210 Computer Organization
Data Hexadecimal.
Coding Concepts (Data- Types)
COMS 161 Introduction to Computing
Introduction to Java, and DrJava
Data Representation ICS 233
A-level Computer Science
Binary to Decimal Conversion
GCSE COMPUTER SCIENCE Topic 3 - Data 3.4 Hexadecimal Conversion.
Hexadecimal.
Introduction to Java, and DrJava part 1
Data Types and Maths Programming Guides.
WJEC GCSE Computer Science
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
Variables and Constants
Chapter 3 - Binary Numbering System
Data Representation COE 308 Computer Architecture
ECE 120 Midterm 1 HKN Review Session.
Presentation transcript:

Section 6 Primitive Data Types

Lesson Objectives Understand why we need data types Recognise the main data types used Know how to convert denary into binary using positive integers Know how to convert binary into denary using positive integers Converting between binary, hexadecimal and denary

Why we need data types Different types of data are stored and processed in different ways. Need to tell computer what type of data it is so it processes it and stores it correctly What ever the data type – it is stored in the computer as binary base 2 (0’s and 1’s)

Data types Type Description Example Character / Char Single letter, digit, symbol (typically using ASCII), control code D, d, 9, %, NULL String A string of alphanumeric characters enclosed in quotes “Hello”, “job”, “£20.99” Boolean One of two values True or false Integer Whole number values with no decimal part (signed or unsigned) 0, -12, 123, 22 Real / floating point Numbers with decimal or fractional parts (signed or unsigned) 25.3, -15.25, -0.2

Number bases Decimal (denary) – 0-9 = Base 10 Binary – 0 and 1 = Base 2 Hexadecimal – 0-9 and A-F = Base 16 These can be written as a subscript: 1110 =11 in denary 112 = binary value 1116 = hexadecimal value (17 in denary)

Representing positive integers in binary First lets look at our denary system The denary number weighting line multiplies by 10 each time it moves to the left Thousands Hundreds Tens Units x1000 x100 x10 x1 So the number 276 is stored as Thousands Hundreds Tens Units 2 7 6

Representing positive integers in binary With binary – base 2 number system The numbers weighting line is multiplied by 2 every time we move to the left 128 64 32 16 8 4 2 1 So every time we move to the left we are doubling

Representing positive integers in binary So how would you fit 25 into binary How many 128 can you fit into 25 How many 64 can you fit into 25 How many 32 can you fit into 25 How many 16 can you fit into 25 25 – 16 = 9 How many 8 can you fit into 9 9 – 8 = 1 How many 4 can you fit into 1 How many 2 can you fit into 1 How many 1 can you fit into 1 1 – 1 = 0 128 64 32 16 8 4 2 1 1 1 1

Representing positive integers in binary So the denary number 25 in binary is: 128 64 32 16 8 4 2 1 This can be confirmed by adding up the weight of the columns that have 1’s in…….. 16 8 1 25

Binary to denary and vice versa Convert the following binary numbers into denary 00010000 00001111 00010001 00000000 10111001 Convert the following denary numbers into binary 140 68 201 What is the largest denary value that can be stored in an 8-bit binary integer?

Representing positive integers in binary – Answers Convert the following binary numbers into denary 00010000 = 16 00001111 = 15 00010001 = 17 00000000 = 0 10111001 = 185 Convert the following denary numbers into binary 140 = 10001100 68 = 01000100 201 = 11001001 What is the largest denary value that can be stored in an 8-bit binary integer? 255

Why is the Hex system used?? Hexadecimal Why is the Hex system used?? 10000 16 10

+78 converted in hexadecimal - First convert into binary Converting denary into hexadecimal +78 converted in hexadecimal - First convert into binary 128 64 32 16 8 4 2 1 Then group in sets of four and change weighting line 8 4 2 1 8 4 2 1 1st four bits equal a value of 4 2nd four bits equal a value of 14 1st hexadecimal value is 4 2nd hexadecimal value is E Denary +78 = 4E in hexadecimal

Converting hexadecimal into denary F2 as a hexadecimal number Each number/letter represents the value of four bits F equals a total of 15 2 equals a total of 2 8 4 2 1 8 4 2 1 Change our weighting line back to represent a binary number 128 64 32 16 8 4 2 1 Add 128+64+32+16+2 = 242 So F2 = 242

Convert Denary to Hex Sheet on intranet