Data Representation
Data Representation
Binary
● Base 2 system
● Made up of 1s and 0s
● A computer contains millions and millions of tiny ‘switches’’ which must be in the ON or
OFF position
● All information in a computer system needs to be converted into the kind of data that can
be represented in switches (1s and 0s) so it can be understood and worked on by a
computer
● Data is processed using logic gates and stored in registers
● A computer register is a fast piece of memory that carries out all calculations in a
computer
● Binary is easier for computers to process, and it also takes up less space
Binary Addition:
● 0+0=0
● 0+1=1
● 1+0=1
● 1 + 1 = 10
Overflow:
● Occurs if the answer to addition is larger than 255 in an 8 bit register - 9 bits instead of 8
● The MSB (Most Significant Bit), so the value to the far left, will be ignored and your value
will therefore be the wrong answer
TWO’S COMPLEMENT
● MSB is reserved as sign bit - it signifies positive or negative
● If MSB is 1 number is negative
● If MSB is 0 number is positive
● Positive → Negative: Change sign bit to 1, flip the bits, add 1 to the binary number
● Negative → Positive: Change sign bit from 1 to 0, flip the bits, add 1
Hexadecimal
● E.g. defining colours in HTML, MAC addresses, assembly languages, debugging
● Base 16 system
● One hex digit represents 4 binary digits
● Hexadecimal is used when developing new software or when trying to trace errors
● Computer memory is machine code/ assembly code
● Using hexadecimal makes it easier, faster, less error prone to write code compared to
binary.
● Using machine code (binary) takes a long time to key in values and prone to errors
● A Memory Dump is the process of taking all information content in RAM and writing it to
a storage drive.
● Developers commonly use memory dumps to gather diagnostic information at the time of
a crash to help them troubleshoot issues and learn more about the event.
● Reading this information in Binary would be unmanageable and therefore the data is
presented in Hexadecimal form
Advantages:
- Less likely to make mistakes
- Uses fewer characters/shorter
- Easier to debug
- Easier to read/write/understand
Character Sets
Sound Representation
● The sounds that we hear and that can travel through the real world come in the form of
analogue waves, analogue waves are continuous.
● This type of wave is completely different to a digital signal which at any one time has to
be in one particular state.
Sound Sampling
● Sampling involves taking a sample of the analogue signal at set intervals
● Sample rate - number of samples taken per second
● This sample is essentially a binary representation of a sound note
Improving Sound File Quality
*Digital sound will never have quality as good as analogue sound as there will always be part of
the sound wave missing between samples. Increasing the sample frequency and bit depth will
improve the quality, however there will always be small parts of the sound wave missing.
File size: To calculate the size of the sound file you simply need to multiply the bit depth by the
number of samples
Example
A sound clip uses 48KHz sample rate, 24 bit resolution and is 30 seconds long.
48000 x 24 = 1152000 bits per second x 30 = 34560000 bits for the whole clip
34560000 ÷ 8 = 4320000 bytes ÷ 1024 = 4218.75 kibibytes ÷ 1024 = 4.12 mebibytes
Compression
Sound
Lossy compression works by taking out the samples of a sound wave that were outside of the
normal human hearing range. Also if 2 sounds played at the same time only louder one is heard
so quieter one is removed E.g MP3
Lossless compression works with sound similarly to Images. Using RLE seeks to spot similar
samples and states how many of those samples are together rather than individually plotting
each sample.
Images
● A bitmap image is made up of a series of pixels (small dots of colour arranged in a grid)
● Each pixel can be represented by a binary code which is processed by a computer
● Resolution = number of pixels in the image. Higher resolution has more pixels meaning
it’s sharper and more detailed, but requires more storage space
● Colour depth = number of bits sued to represent each colour. Higher colour depth
means more realistic image b/c more colours represented but more storage space
● E.g. 8 bit colour depth allows 256 colours to be represented
● Quality and file size increase as resolution and colour depth increase
example
An image measures 100 by 80 pixels and has 128 colours (so this must use 7 bits)
100 x 80 x 7 = 56000 bits ÷ 8 = 7000 bytes ÷ 1024 = 6.84 kibibyte
● Lossy: Permanently removes data and tries to reconstruct image without missing data
● Significant file size reduction but low quality
● Similarly coloured pixels are all made the same
● E.g JPEG
● Lossless: Uses RLE to spot patterns of similarly coloured pixels. It then stores the
pattern as an instruction and image can be reconstructed to original quality
● Finds groups of repeating data and records data and no of times it was repeated
● Can perfectly reconstruct image but file size isn’t largely reduced
● E.g PNG
Why Use Compression?
● Shorter transmission time
● Less bandwidth required
● Less storage space required
● Smaller packets/fewer packets/faster transmission
● Reduces internet traffic
● Better streaming
Data Storage
● A nibble = 4bits
● 1 byte = 8 bits
● 1KiB = 1024 bytes
● MiB
● GiB
● TiB
● PiB
● EiB