4.5 Data representation Flashcards
Write down the natural numbers
{ 0, 1, 2, 3, …}
What are ordinal numbers?
Natural numbers used to describe the numerical position of a value. e.g. in the alphabet (1st 2nd etc.)
Why use hexadecimal?
Long sequences of binary digits are hard for humans to read and understand, so hexadecimal is often used as a shorthand
How many bytes in a megabyte?
One million
How many bytes in a mebibyte?
1024^2 (or 2^20)
List the prefixes starting kibi…
- kibi
- mebi
- gibi
- tebi
What is the significance of the leftmost bit in two’s complement?
The most significant bit (leftmost) is the sign bit, which represents a negative number when set to 1
What is 1111…111 in two’s complement binary?
-1
Range of 8 bits for:
1. unsigned binary number
2. two’s complement number
Unsigned: 0 to 255
Two’s complement: -128 to 127
The sum of two 8-bit two’s complement binary numbers can be between ___ and ___
-128 and 127
(Can ignore the overflow in this case)
How to turn a negative number into a positive number in two’s complement (and vice versa)?
- From the right, up to and including the first 1 stays the same.
- Everything other value gets flipped.
(This is the same as flipping everything then adding 1)
How to subtract two binary numbers A - B?
- Convert B into two’s complement
- Add this to A
How can you identify normalised floating point numbers?
Mantissa must begin with 01 or 10
2 advantages of normalisation of floating point numbers
- It maximises precision for a given number of bits
- It ensures that there is a unique representation of each number, making it simpler to test for equality of numbers
If the exponent of a number is negative, what do you need to do to the mantissa when converting from binary to decimal?
Fill in with 0s if the leftmost bit is a 0, and fill in 1s if its a 1.
Advantages of fixed point binary numbers
- More representable numbers, as numbers don’t need to be normalised
- Maximum precision for the given number of bits
- Can be simpler, and faster, to work with
3 advantages of floating point numbers
- Can represent a much larger range of numbers
- The trade-off between range and precision can be tailored to the context the system is being used in
- Additional non-numeric values can be represented using the unnormalised range (e.g. NaN, infinity)
What is meant by the precision of a binary number?
The maximum number of significant digits that can be represented in a number format.
When the result of an arithmetic operation is a real number (e.g. pi), what options are there for storing it in binary?
- Rounding to the nearest representable value
- Truncating
What is absolute error?
The difference between the actual value and the nearest representable value
(always positive)
What is relative error?
The absolute error ÷ the actual value
(could be given as 0.05, 1/20 or 5%)
When does overflow occur?
When a number is too large to be represented using the available number of bits
When does underflow occur?
When a number is too small to be represented using the available number of bits
What is a character set?
A character set is a standardised collection of characters and the bit-patterns used to represent them
How many bits does ASCII use? How many characters can it represent?
- ASCII uses 7 bits to represent characters (hence max 128 characters)
- However, 8 bits are used to store each character (preceding 0)
- The leading 0 sometimes used as parity bit instead
How does ASCII work?
- Each of the characters is assigned a denary character code
- Which is represented and stored in the computer as binary
What is the downside of ASCII?
ASCII is not sufficient to represent all of the languages and scripts used around the world
Why is unicode needed?
- ASCII can’t represent all languages and scripts
- ASCII can’t represent all possible symbols
- The World Wide Web made it important to have a universal international coding system
Which is the most common unicode encoding standard used?
UTF-8
How does UTF-8 (unicode) use variable width encoding?
UTF-8 can be expanded to a greater number of bits when dealing with larger sets of characters
What are the first 128 codes in unicode the same as?
The first 128 codes in ASCII
Example of where parity bits are typically used
In the transmission of 7-bit standard ASCII codes
What is a downside of majority voting?
If you choose a large odd number of repetitions, there is lots of redundant information that needs to be transmitted across the channel
What is a checksum? (3*)
- A checksum is a piece of data that is added to a block of data to enable error detection.
- It is produced by applying a checksum algorithm (often MOD to limit magnitude of checksum).
- The receiver recalculates the checksum and if it doesn’t match the data’s checksum then there is an error in the data
What is a check digit? (3*)
- An extra digit that is placed at the beginning or end of a number and is used to identify a product or verify a user
- It allows for error detection
- They are produced by algorithms that often use modulo arithmetic
What is a bitmapped graphic made of?
A grid of pixels
What is a pixel?
- Pixel is short for picture element
- It is the smallest addressable area of an image
What is colour depth?
The number of bits used to represent the colour of a single pixel in a bitmap image
What determines the minimum colour depth?
The number of different colours that need to be used in an image
What is the image size in pixels?
(image width in pixels) * (image height in pixels)
What is the image resolution measured in?
dots per inch (ppi)
How do you calculate image file size? (ignoring metadata)
file size
= (image size in pixels) x colour depth
= (image width in pixels) x (image height in pixels) x colour depth
5 examples of metadata for a bitmap image
- Image width in pixels
- Image height in pixels
- Colour depth
- File format
- Geographical location of creation
How are vector graphics stored?
- Images are described using a list of objects.
- The properties of each object in the vector graphic image are also stored as a list
5 examples of properties of objects in a vector graphic image
- Coordinates of object
- Shape
- Border colour
- Fill colour
- Border thickness
3 advantages of vector graphics
- Vectors can be enlarged without distortion, whereas bitmapped graphics can look pixelated when the size changes
- In general, vector graphics tend to result in smaller file sizes. Especially when they are composed of relatively simple geometric shapes
- It is much simpler to create and edit vector graphic images as each object in a vector graphic can be adapted independently by accessing its set of attributes
What is the advantage of bitmapped graphics?
- The variety of images that can be created by the geometric shapes implemented by vector graphics is limited.
- On the other hand, bitmapped graphics can depict almost any level of complexity and detail.
- Photographs are always stored as bitmaps.
What are vector graphics mostly used for?
Illustrations and logos
What is symmetric encryption?
When the same key is used for both encryption and decryption
What does computationally secure mean for a cipher?
A cipher is computationally secure if it cannot be cracked in ‘reasonable time’.
What are disadvantages of Caesar cipher?
- Easy to crack because there are only 25 keys
- → so very quick to crack with brute force
- Frequency analysis reveals the likely shift
- Word structure is preserved
- Key length is such shorter than the message
- So NOT computationally secure
What is encryption?
The process of converting plaintext to ciphertext, so that it cannot be understood if intercepted
What is special about a Vernam cipher key?
- The key is randomly generated, or taken from a ‘one-time pad’.
- and key length = plaintext length
What operation does the Vernam cipher use for encryption and decryption?
XOR
What are the 5 conditions for perfect security?
- Key is chosen truly randomly
- Key is only used once
- Key is known only to the sender and receiver
- Key must be destroyed after use
- Key length at least message length
What does MIDI stand for?
Musical Instrument Digital Interface
Describe what MIDI is and what its purpose is
- MIDI is a technical standard that describes
1. A protocol
2. Digital interface
3. Standard set of connectors - MIDI allows for a wide range of electronic musical instruments to communicate with each other so as to manipulate music
Describe the use of event messages in MIDI. Include examples of event messages.
Event messages are a list of instructions that specify how the music should be played. For example
- Note on / note off
- Pitch
- Volume
- Instrument
- Vibrato
3 advantages of using MIDI files for representing music
- A MIDI file provides a more compact representation of sound, often leading to MIDI files using far less storage than an equivalent sampled recording.
- The performance data can be easily manipulated (e.g. duration of a note can be changed, or even an entire instrument)
- No information about a note is lost through sampling
Difference between analogue data and digital data
- Analogue data is continuous, there are no limits to the values that the data can take
- Digital data is discrete, meaning that it can only take particular values.
Where do ADCs get the analogue signal from?
Analogue sensors
Most common use for a DAC?
Converting a digital audio signal to an analogue audio signal
Why are files compressed?
- To reduce their size
- Smaller files can be transferred faster between storage devices or over the internet
What is lossy compression?
- When the file is compressed, there is loss of information from the original version.
- When decompressed, the file will be lower quality than the original
Name two methods of lossless compression
- Run length encoding
- Dictionary-based compression
How does run length encoding work?
RLE reduces the size of a file by removing repeated information and replacing it with one occurrence of the repeated information followed by the number of times it is to be repeated
When are RLE and dictionary-based compression most effective?
On files that contain a lot of repeated data
True or False: relative error is always given as positive
True (in this A-level)
What is sampling rate measured in?
Hertz
What does Nyquist’s theorem state?
The sampling rate must be at least double the highest frequency present in the signal
What is the advantage of lossless compression?
The size of a file can be reduced without decreasing its quality (there is no loss of information)
What is the key difference between lossy and lossless compression?
Lossy : original data cannot be recovered. lossy compression cannot be reversed
Lossless : original data can be fully recovered. lossless compression can be reversed
Describe how dictionary-based compression could be used on a paragraph of text
- Each word in the text is allocated a shorter code
- The paragraph is then represented as a sequence of these codes
- The dictionary containing the repeated data is appended to the file
What is a bit?
- The fundamental unit of information
- A bit is either 0 or 1
What does ASCII stand for?
American Standard Code for Information Interchange
If the actual number is A, but B is stored, what is the absolute error?
|A-B|
absolute error is positive
Describe the principles of operation of an ADC
- Analogue signal is sampled at regular time intervals
- Amplitude of signal at each sample point measured
- Measurement is coded into a fixed number of bits
4 reasons the Vernam cipher can be considered perfectly secure
- Key length = plaintext length
- The ciphertext contains no useful information about the plaintext
- Bruteforce would reveal every possible plaintext
- Frequency analysis does not help as ciphertext letters have uniform probability