P1 - Unit 1 - Data Representation
P1 - Unit 1 - Data Representation
Kibibyte or kilobyte?
• 1 kilobyte is 1000 bytes
• 1 kibibyte is 1024 bytes
1000 100 10 1
2 7 0 3
2x1000 + 7x100 + 0x10 + 3x1 = 2703
Binary systems
Unit 1 Data representation
Binary to Denary
128 64 32 16 8 4 2 1
1 0 0 1 0 1 1 0
Bit values which are one/ 1 , their place values will be added
128+16+4+2 = 150
Binary systems
Unit 1 Data representation
128 64 32 16 8 4 2 1
1 0 0 1 1 1 0 1
Binary systems
Unit 1 Data representation
Denary to binary
• How do you convert 28 to binary?
• Method
• Working right to left, write out the numbers 1, 2, 4, 8 and so on, doubling each time to
128
128 64 32 16 8 4 2 1
0 0 0 1 1 1 0 0
• 128, 64 and 32 are all greater than 28, so put a zero for these
• Put a 1 in the 16 column, 28-16=12
• Put a 1 in the 8 column, 12-8 = 4
• Put a 1 in the 4 column, 4-4=0 so put zero in other columns
Hexadecimal
Unit 1 Data representation
Hexadecimal
• Hexadecimal (or hex) is a number system which
uses base 16
• As we only have 10 digits, it uses 0-9 and then the
letters A to F
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F
• What is F in denary? 15
• What is 10 in hex? A
Hexadecimal
Unit 1 Data representation
16s Units
2 A
2x16 + 10 = 42 in denary
Binary addition
• Use binary to add two numbers together
1 + 1 = 10?
Simple denary
Hexadecimal
addition
Unit 1 Data representation
binary addition
Unit 1 Data representation
1. 0 + 0 = 0 11
2. 0 + 1 = 1 1 1 1 0 14
3. 1 + 0 = 1 + 1 1 0 0 12
4. 1 + 1 = 0 Carry 1
= 1 1 0 1 0 26
Rule 2 or 3
5. 1 + 1 + 1 = 1 Carry 1
Carry Bit
Rule 5
Rule 4
Rule 1
Hexadecimal
Unit 1 Data representation
11
Carry 1
101 01
+ 1 11
=111 00
Hexadecimal
Unit 1 Data representation
Adding numbers
• Computers work with a fixed number of bits at a time
• This can cause problems
• What problem will arise when adding the following bytes and storing the result in one
byte?
11110000
+10011111
Hexadecimal
Unit 1 Data representation
Overflow error
• When the result of an addition is too large for the number of bits the
computer works with, there will be an overflow error
1 1 1 1
1 1 1 1 0 0 0 0
1 0 0 1 1 1 1 1
+ 1 1 0 0 0 1 1 1 1
9th Bit
Binary shifts and two’s complement
Unit 1 Data representation
128 64 32 16 8 4 2 1
23 0 0 0 1 0 1 1 1
0 0 1 0 1 1 1 Move bits to the left
46 0 0 1 0 1 1 1 0 Put zero in the least
significant bit
Binary shifts and two’s complement
Unit 1 Data representation
128 64 32 16 8 4 2 1
90 0 1 0 1 1 0 1 0
0 1 0 1 1 0 1 Move the bits to the right
45 0 0 1 0 1 1 0 1 Put zero in the most
significant bit
Binary shifts and two’s complement
Unit 1 Data representation
Two’s complement
• -15 is represented by the two’s complement:
• 1111 0001
Two’s complement
• What does the following two’s complement negative
number represent?
1011 0001
128 64 32 16 8 4 2 1
1 0 1 1 0 0 0 1
0 1 0 0 1 1 1 0 Invert the bits
0 1 0 0 1 1 1 1 Add 1
File size= 6 *4 *3
= 72 bits
= 72/ 8
= 9 bytes
ASCII and Unicode
Unit 2 Data representation
Image resolution
• Resolution is the number of pixels in the image
• High definition (HD) television uses a resolution of
1920 × 1080 pixels
• The first iPhone had a resolution of 320 × 480 pixels
ASCII and Unicode
Unit 2 Data representation
Images
Unit 1 Data representation
Image Size
20 pixels
File size of image=Resolution x bit Depth
20 pixels
( check previous slide to how to find colour depth)
File size = 20 x 20 x 3
= 1200 bits
=1200/ 8 bytes
= 150 bytes
8 colours
Images
Unit 1 Data representation
Benefits of compression
• Compression is often used
for files and data that are
sent via the internet
• Transmission times are
reduced meaning that
downloads happen faster
• Data allowances go further
• Less bandwidth is required
• Less storage space is required
to save files
Data storage and compression
Unit 1 Data representation