Download presentation
Presentation is loading. Please wait.
1
Section 6 Primitive Data Types
2
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
3
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)
4
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, , -0.2
5
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)
6
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
7
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
8
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
9
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
10
Binary to denary and vice versa
Convert the following binary numbers into denary 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?
11
Representing positive integers in binary – Answers
Convert the following binary numbers into denary = 16 = 15 = 17 = 0 = 185 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? 255
12
Why is the Hex system used??
Hexadecimal Why is the Hex system used?? 10000 16 10
13
+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 nd four bits equal a value of 14 1st hexadecimal value is nd hexadecimal value is E Denary = 4E in hexadecimal
14
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 = So F2 = 242
15
Convert Denary to Hex Sheet on intranet
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.