Topic 2 - Data Flashcards
What is binary used for?
To represent data and program instructions.
How is data represented in a computer system?
As patterns of bits.
What is a nibble?
A group of four bits.
What is a byte?
A group of eight bits.
The formula for calculating how many unique binary patterns can be generated by n bits is 2^n, where n is the number of bits.
…
What is a denary number?
A decimal number.
What are the place values in a binary system?
128 64 32 16 8 4 2 1
What method is used to represent a signed number?
Two’s compliment.
In two’s compliment what makes a number negative?
If the most significant bit (MSB; the leftmost bit) is 1.
In two’s compliment what makes a number positive?
If the most significant bit (MSB; the leftmost bit) is 0.
Describe how two’s compliment works when converting a negative binary number to its positive binary equivalent.
1) Write it out
2) Flip all the bits
3) Add 1
Describe how to find a negative number using two’s compliment notation.
1) Write it out in binary
2) Flip all the bits
3) Add 1
How would you calculate a subtraction of denary numbers in binary?
1) Convert the first number to binary
2) Convert the negative number to binary using two’s compliment
2) Carry out the rules of addition
How does logical shift left work?
- Move each binary digit n positions left.
- Discard the leftmost n bits.
- Fill up the empty spaces on the right with 0’s.
How does a logic shift right work?
- Shift each binary digit n positions right.
- Discard the rightmost n bits.
- Fill up the empty spaces on the left with 0’s.
How is an arithmetic shift right different to a logic shift right?
The vacant spaces on the left are filled with the value of the original most significant bit.
What is an overflow?
When an operation produces a result that requires more bits to store it than are available in the computer.
How do you respond to an overflow?
A 9th bit is required. The programmer must make allowances for this to prevent serious errors or disasters.
What are the consequences of an overflow error?
- the program may crash
- the program may produce unreliable or incorrect results
What is hexadecimal?
Hexadecimal numbers represent long binary numbers using fewer digits. Every eight digits of a binary number can be represented by two hexadecimal digits.
How do you convert binary to hexadecimal?
- Split the 8-bit byte into two 4-bit nibbles
- Convert the bits in each nibble into denary numbers using the place values
- Add these together to give the hexadecimal
How do you convert the hexadecimal to binary?
- Each hexadecimal digit is converted to denary
- Each denary number is converted into a nibble
- The nibbles are combined to give the binary number
What are the three uses of hexadecimal?
- To help humans cope with long strings of binary digits - they’re much shorter in hex.
- When a computer malfunctions, error code numbers are usually given in hexadecimal.
- Hexadecimal is also used to represent numerical values in assembly language.
What are the three uses of hexadecimal?
- To help humans cope with long strings of binary digits - they’re much shorter in hex.
- When a computer malfunctions, error code numbers are usually given in hexadecimal.
- Hexadecimal is also used to represent numerical values in assembly language.
What is ASCII code?
A 7-bit code there are 128 (2^7) code sequences representing English characters and control actions such as SPACE and SHIFT.
How do computers represent text characters, numbers and symbols?
In binary as strings of 1’s and 0’s.
What is a character set?
The list of binary codes that can be recognised by the computer hardware and software.
In Python what does the function ord() do?
Returns the ASCII code (in denary) for a character.
code = ord(“c”) — returns 99
In Python what does the function chr() do?
Returns the character for a denary code.
char = chr(100) — returns “d”
How are images represented in a computer?
As strings of 1’s and 0’s.
What is colour depth?
The number of bits used to encode the colour of each pixel.
What makes an image more detailed?
The more bit’s there are to encode the colour.
What is resolution?
The number of pixels per inch when the image is displayed.
What are analogue recordings?
Sound recordings convert the changes in air pressure into voltage changes.
What is the sample interval?
Samples of sound wave are taken at regular fixed intervals.
Define sample rate.
The number of samples over a given time period.
What does a high sample rate do?
Gives a more accurate reproduction of the sound’s analogue waveform.
Define sample.
Transistors are either on or off, and cannot continuously reproduce analogue changes. Instead, digital recordings use snapshots of the sound at regular fixed intervals and then play them back one after the other.
Equation for the size of an audio file.
file size (bits) = sample rate x bit depth x recording length (seconds)
What can be represented with unsigned integers?
4 bits can represent the numbers 0 to 15 and 8 bits can represent the numbers 0 to 255.
What can be represented with signed integers?
4 bits can represent the numbers -7 to 8 and 8 bits can represent the numbers -127 to 128.
How many characters does the 7-bit ASCII character set give?
128 (2^7)
Define bit depth.
The number of bits used to represent a single sample of audio.
Define colour depth.
The number of bits used to represent the colour of each pixel in an image.
1 byte = …
2^0 bytes
1 kibibyte (KiB) = …
2^10 bytes = 1024 bytes
1 mebibyte (MiB) = …
2^20 bytes = 1024 kibibytes
1 gibibyte (GiB) = …
2^30 bytes = 1024 mebibytes
1 tebibyte (TiB) = …
2^40 bytes = 1024 gibibytes
How can the size of large files be reduced?
Using compression algorithms that repackage the data or remove some of it.
What does lossless compression do?
- reduces file size without deleting any data
- nothing is lost
What does lossy compression do?
- reduces file size by deleting some data
- the original can never be reconstructed - it has been irreversibly changed
How does lossless compression compress?
Looks for redundancy where the same data is stored many times and groups data into one reference.
How does lossy compression compress?
- In image files, algorithms analyse the image and find areas where there are only slight differences. These are given the same value and the file can be rewritten using fewer bits.
- In digital sound recordings very small variations in frequency, tone and volume are removed to reduce the file size as the human ear cannot detect these small differences.
When is lossless used?
- text files
- graphic files with a low colour depth
What is lossless bad at compressing?
- audio files
- 24-bit colour files
When is lossy used?
- image files
- digital sound recordings
What is lossy bad at compressing?
- text files
- executable software
What does compression help with?
Smaller file sizes make file transfer more efficient and reduce the requirements for storage space.
What are the advantages of file compression?
- less internet bandwidth is used when files are downloaded/ uploaded
- transfer time is faster
- less storage space is needed
- smaller files reduce congestion on the internet
- audio and video files can be streamed