Data Representation Flashcards

(103 cards)

1
Q

Why do computers use binary?

A

• Computers understand only two states: power on, or power off
• This is represented by switches, and computers are essentially calculators made up of billions of switches where…
• Power on = 1
• Power off = 0
Hence, it stores data as binary, consisting of only 0s and 1s.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Everything that a computer needs to process/store…

A

Must be converted into binary format (eg. numbers, text, images, sound, programs instructions are all stored as a collection of binary digits)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

1 bit is…

A

A single 0 or 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A nibble is…

A

4 bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A byte is…

A

8 bits (eg. one character of text)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

a kilobyte (KB) is…

A

1000 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

a megabyte (MB) is…

A

1 000 000 bytes, or 1000 kilobytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A gigabyte (GB) is…

A

1 000 000 000 bytes or 1000 MB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A terabyte (TB) is…

A

1000 GB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A petabyte (PB) is…

A

1000 TB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

One character takes up…

A

1 byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A full page of text takes up…

A

30 KB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

One small digital colour photograph takes up…

A

3 MB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Music CD capacity is…

A

650 MB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

DVD capacity is…

A

4.5 GB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Hard disk capacity is…

A

1 TB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How many values can you have with 1 bit?

A

2

With 2 bits, it is 4
3 bits: 8
4 bits: 16

To find the number of combinations for the number of bits, do:
2 ^ (the number of bits available)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Binary vs denary

A

• Denary is a base 10 number system with 10 digits 0-9
• Binary is a base 2 number system with 2 digits, 0 and 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is 10010110 in denary?

A

128 + 16 + 4 + 2 =150

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Convert 56 into 8-bit binary

A

00111000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is 10010110 in denary?

A

128 + 16 + 4 + 2 =150

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the MSB?

A

It is the most significant bit, or the bit with the largest value. This is the bit furthest to the left.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the LSB?

A

It is the least significant bit, or the bit with the smallest value. This is the bit furthest to the right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is the largest number that can be represented with n bits?

A

2^(n) - 1

Remember: the total number of values that can be represented is 2^(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How can you quickly differentiate between even and odd numbers in binary?
If there is a 1 at the end, it is odd. If there is a 0, it is even.
26
What is 0101 1001 in denary?
89
27
What is 1100 0010 in denary?
194
28
What is 14 in binary?
0000 1110
29
What is 105 in binary?
0110 1001
30
Rules of binary addition
1. 0 + 0 = 0 2. 0 + 1 = 1 3. 1 + 0 = 1 4. 1 + 1 = 0 Carry 1 5. 1 + 1 + 1 = 1 Carry 1
31
What are 10101 and 111 added?
11100
32
What error can be made with adding binary?
**An overflow error.** • Computers work with a fixed number of bits at a time • When the result of an addition is too large for the number of bits the computer works with there will be an overflow error Eg. If there is an extra 1 past the 8-bits, there is an overflow error.
33
What error can be made with adding binary?
**An overflow error.** • Computers work with a fixed number of bits at a time • When the result of an addition is too large for the number of bits the computer works with there will be an overflow error Eg. If there is an extra 1 past the 8-bits, there is an overflow error.
34
What happens in a left binary shift operation?
• A binary shift left of one bit moves all the bits one place to the left • The vacant bit spaces are filled with zeros. This doubles the binary number. A shift by 2 to the left would quadruple it, etc.
35
What happens in a right shift binary operation?
A binary shift right of one place results in halving the number and **rounding down** each time. Empty spaces are, again, replaced by a 0.
36
Left shifts…
Multiply
37
Right shifts…
Divide
38
What can logical shift operations do?
• Logical shifts can very quickly multiply or divide a binary number by a factor of two
39
Problems with left shifts
Overflow error • If there’s a limited number of bits available to store the result, overflow can occur with logical shifts left.
40
Problems with right shifts
Loss of precision • However, with right shifts a loss of accuracy can occur as bits are lost: • E.g. Right Shift by 2 places: 22 / 4 is not exactly 5
41
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 - 0 1 - 1 2 - 2 … 9 - 9 10 - A 11 - B … 15 - F
42
How to convert hex into denary?
Hex uses base sixteen. You will only ever need to translate one or two digit hex. So… 16s Units 2 A 2 x 16 + 10 =42 in denary
43
What is denary 27 in hex?
27 = 1 x 16 r 11 (11 = B in hex) so = 1B
44
What is hex 27 in denary?
2 x 16 + 7 =39
45
How to convert hex into denary?
Hex uses base sixteen. You will only ever need to translate one or two digit hex. So… 16s Units 2 A 2 x 16 + 10 =42 in denary
46
What is denary 44 in hex?
2 x 16 remainder 12 (12 is C in hex) = 2C
47
Denary to hex conversion
• Divide the denary number by 16 to get the number of 16s (the left-hand hex digit) • The remainder gives you the units Denary 18 becomes: 18 / 16 = 1 remainer 2 so the hex value for 18 is 12
48
Binary to hex conversion
1. take a binary word of 8 bits 11100101 2. Divide into two nibbles of 4 bits 1110 0101 3. Convert each nibble into its hex value and rejoin 1110 = 14 = E in hex + 0101 = 5 in hex So 11100101 = E5 in Hex
49
Hex to binary conversion?
Split the two hex characters 3 = 0011 in binary and B = 1011 So 3B = 0011 1011 in binary
50
Computers **DO NOT**
Use hex, it is entirely for human benefit
51
Why do we use hex?
• It is much simpler to remember a hex value than a binary value • It is quicker to write or type since a hex digit only takes up one bit rather than 4 bits • People are less likely to make an error with fewer digits • It is easy to convert between hex and binary
52
Where is hex used?
- MAC Addresses - IP Addresses - Colours - hex colours use sixteen different values to represent a single shade of colour, whether it be red, green or blue. This is powerful because it gives you a broad range of shades for each colour - specifically 16.
53
Representing characters in binary
• Every character on the keyboard is represented by a unique binary value • Uppercase letters (capitals) have different values from lowercase characters • Numbers have their own values • Punctuation symbols have their own character code
54
What is a character set?
A common character set is required so that data is readable by ALL computer systems - for communicating and exchanging data with each other. The character set defines which character code (unique binary value) corresponds to each character. A standardised collection of characters and the bit patterns used to represent them is called a character set. There are two major character sets in use today: • ASCII • Unicode
55
ASCII character set
• ASCII (American Standard Code for Information Interchange) has become the standard code, used worldwide • It encodes 256 characters into 8-bit binary codes • Characters include numbers 0 to 9, uppercase and lowercase letters A-Z, a-z, punctuation symbols and the space character In ASCII, character codes are commonly grouped and run in sequence. A-Z characters are from 65-90.
56
If capital A is 65 or 01000001, what is capital E?
69 (0100 0101)
57
ASCII character code vs denary value
The ASCII character code for ‘7’ is 55 • 55 (0011 0111) is the ASCII character code that represents the character ‘7’ • This is clearly not the same as the equivalent binary value for 7 (00000111)
58
You cannot do…
Arithmetic with ASCII
59
How do programming languages deal with the input of numbers if ASCII cannot do arithmetic?
• Programming languages deal with the input of numbers in different ways • In some languages, variables have to be declared as type **char, string, integer, real** etc. at the beginning of the program • In other languages such as Python, all data is input as string, and if it is to be regarded as an integer, it has to be converted using an inbuilt function e.g. xString = input (“Enter an integer: ”) x = int(xString)
60
ASCII Limitations
Ascii (actually extended ASCII) has 8 bits, meaning it can only represent 256 characters, which is not enough for many different alphabets (eg. Japanese, Mandarin, Arabic)
61
What is Unicode?
Unicode was developed to use 16 bits (= 65 536 possible characters): • Introduced to standardise the encoding of characters from all languages (e.g. Greek or Russian letters, Chinese characters and letters with accents) The first 256 characters of Unicode are the same as ASCII therefore ensuring backward compatibility
62
Unicode limitations
However, whilst Unicode enables many more characters to be represented, every character requires twice as much storage space (16 bits vs 8 bits). Strictly speaking Unicode is of variable length and can be as much as 32 bits per character.
63
Storing images digitally
• Digital images can be stored on a computer in many different file formats • BMP • JPG • GIF • PNG • TIFF
64
Bitmap images
• Bitmap images are made up of pixels • A pixel is the smallest identifiable area of an image • Each pixel is a single colour and is given a binary value which represents that colour e.g. 111100000000 might equal red • A pixel’s colour can be changed by changing this value
65
What is image resolution?
• Resolution is the concentration of pixels within a specific area: • Typically it is the number of pixels per inch: – e.g. 72 PPI (Pixels Per Inch) = typical screen resolution – Smartphones may have very high resolutions (300+ PPI) • Or it’s the size of the image (its dimensions - height and width)
66
The higher the number of pixels per inch/resolution…
The higher the image quality
67
How is an image created by a computer?
• Each pixel is given a binary value • Each binary value represents a different colour • Using one bit per pixel allows only 2 values: • 0 and 1 1 = Black, 0 = White
68
Increasing the number of bits per pixel increases…
The number of colour combinations 1 bit - 2 colours 2 bits - 4 colours 3 bits - 8 colours Where n is the number of bits per pixel: It is… 2^(n) colours
69
What is colour depth?
Colour Depth = the number of bits used to store the colour for each pixel Changing this affects the number of colours an image can display
70
Colour or bit depth affecting
• Each pixel can represent a finite number of colours • A pixel is attributed a number of n bits • The number of combinations (2^n) dictates the colour depth and therefore the number of colours that can be represented • A higher colour depth gives a greater range of colour and a better quality of image 8 bits per pixel = 2^8 = 256 colours 16 bits per pixel = 2^16 = 65,536 colours 24 bits per pixel = 2^24 = 16,777,216 colours
71
Total file size of an image calculation
Resolution/ number of pixels x colour depth Remember 8 bits =1 byte
72
Higher bit depth…
Means higher file size
73
Higher resolution…
Means higher file size
74
What is the unit of image resolution?
ppi = pixels per inch
75
Why is the stored file size on disk larger than the actual file size?
Due to the metadata stored with the image
76
What is image metadata?
• Metadata is data about data • It is data other than image data that is stored with a file • This will include: • Colour depth in bits per pixel • Dimensions of the image (its height and width in pixels) • Date created • Author **NB: The 'name' of the file is not included**
77
Analogue vs digital sound
• Analogue sound signals are continuous • Digital signals are discrete
78
Draw an analogue sound
N/a
79
Draw a digital signal
N/a
80
How is sound digitized?
by repeatedly measuring and recording the sound wave, ie. SAMPLING
81
Analogue to digital converters
• Sounds must be converted into a digital form in order to be stored and processed by a computer • An Analogue to Digital Convertor (ADC) is used to convert inputs to digital signals • A Digital to Audio Convertor (DAC) is used to convert digital signals to outputs Microphone —> ADC —> Processing —> DAC —> Speaker
82
Sound sampling
• A sound sample is a measurement of amplitude of a sound wave at a given time • Sound is sampled using a bit depth and sample rate
83
What is bit depth?
= the number of bits available to store each sample - The more bits available, the more closely the wave is sampled on the y-axis
84
The higher the bit depth
The higher the accuracy of the height of wave measurement, but also the higher the file size
85
What is the sample rate?
= the number of samples taken per second - it is measured in hertz (Hz)
86
What are hertz conversions?
1 Hz = 1 sample per second 1 KHz = 1000 samples per second 1 MHz = 1 000 000 samples per second 1 GHz = 1 000 000 000 samples per second
87
The higher the sample rate
The higher the accuracy, the higher the file size
88
How to calculate sound file sizes?
File size (bits) = samples rate x bit depth x duration
89
Digitised sound quality
• Recording quality improves: • the more frequently we sample the sound • the more accurately we record the wave height • Increasing the sampling rate means recording more data points • Increasing the bit depth improves the accuracy of each data point
90
Compression
• Compression is the name given to algorithms which reduce file sizes • Decompression is the process where compressed data is restored to its original format • Compression is heavily used with sound, image and video files
91
What are the two types of compression?
- lossy compression (JPG, GIF, MP3) - lossless compression (PNG, TIFF)
92
Lossy compression
Lossy compression reduces the file size by permanently removing some data. The original **cannot be restored**.
93
What would lossy compression be good or bad for?
Good: images, videos, sounds Bad: documents, computer programs
94
Lossy image compression
• Removes data permanently • Constructs the image minus the data which has been removed • Much smaller file sizes but some loss of quality
95
How does lossy compression work in images?
Similarly coloured pixels are all made the same -> essentially reducing the number of colours (reduces colour depth)
96
How does lossy compression work in audio?
Lossy compression removes sounds that we can’t easily hear or that least affect the perceived playback quality
97
Lossless compression
• Compresses data files by storing all of the same data, but in a different way • Therefore doesn’t lose any of the original information so is... • Reversible so that the original data can be reconstructed HOWEVER….not all data files can be compressed using Lossless compression AND the compressed data must be decompressed to be used, and this takes time, which may be detrimental to some applications
98
How does lossless text compression work?
• Finds patterns in the original text • Encodes each pattern in a dictionary • Ie. multiple original characters are replaced With a single digit (stored in binary) Repeated words or numbers or symbols are stored as one binary digit
99
How does lossless image compression work?
• Finds groups of repeating data and records the data only once along with the number of times it was repeated Eg. For this: ;;;;====—— It would do 4 x ; + 4 x = + 2 x — • When data is uncompressed it is restored exactly as it was in the original LOSSLESS COMPRESSION looks for patterns and substitutes these with something smaller but so that can recreate the original file (eg. repeating words / phrases in text files, repeating pixels in images)
100
Why is compression used?
Compression is often used for files and data that are sent via the internet • Download times are reduced • Data allowances go further • It is possible to transmit video and music data streams as fast as they are playing • Images inside web pages appear faster -> speeds up transmission of webpages • Reduces space on disk / servers
101
Benefits of compression
• Smaller files = fewer packets = faster transmission time • Quicker to complete transmission • Reduces traffic over the Internet • Reduces download times of video, sound (including speech used for VOIP systems) and image files • Streaming is also possible as the data can be sent as fast as the rate it is played • Images inside web pages appear faster -> speeds up transmission of webpages • Reduces storage requirements on disk / servers
102
Video streaming
• The files for video streaming are compressed • The TV or computer needs to decompress the data as it is playing the video • Before the video begins playing, it will buffer a sufficient amount to allow for the network occasionally being slow • If the website or server detects that the connection is slow, it may be able to start sending an alternative lower quality file
103
Different file formats
JPEG (photos), MP4 (videos), MP3 (music) are lossy PNG (images/photos), ZIP (documents), GIF (simple images, sometimes with animation) are lossless