Unit 1 Flashcards
Why binary
Binary is a base 2 number system that uses only 1 (on) and 0s (off) to represent values and data.
Computers use binary because they can only understand 0 and 1s, and they use logic gates that uses on and off.
Hexadecimals
Base 16 number system easier to read for humans.
Used in:
- represent colors (#FFFFFF is white)
The amount of RBG each in 2 digits RRBBGG
- show error messages (shorter than binary)
- debugging
- MAC address
- assembly language
- URL strings
Two’s complement causing errors
Logical left shifts can cause an overflow error: when the result of a calculation is too large to be stored within the available number of bits allocated for the data. It can cause the computer to crash.
(Logical right shift one place, divided by 2, cause rounding error, binary cannot represent 0.5)
How character is represented
To store values on a computer, you have to digitalize, encode, then store as binary value. Computers store characters as binary values, each code point representing a character.
ASCII AND UNICODE
ASCII (American standard code for information interchange):
- Uses 7 bits to encode characters
- Can represent 128 different characters
- ‘A’ in ASCII is 65, ‘a’ is 97 (capital and lowercase has a difference of 32)
- Extended ASCII uses 8 bits, can represent 256 characters
Unicode:
- Uses 16 bits per character (2 bytes)
- Use more storage than ASCII
- Can represent 65,536 characters, more than enough to represent every character in every language
- Used to represent emojis
- Extended Unicode uses 21 bits
Representing images
A pixel is the smallest piece of an image. Each pixel is assigned a binary number that represents its colour. A digital image is made up of a collection of these pixels, stored as binary.
Image resolution refers to the number of pixels within an image, typically width*height.
Bit depth (or colour depth) of an image is the number of bits per pixel. For example, if the bit depth is 2, we do 2^2, meaning you can represent 4 colours.
Representing sounds
In the physical word, sound are analogue waves. Digital sounds are digital waves, a sequence of discrete signals.
The computer uses sampling to represent analogue waves in digital format. It does this by taking measurements of the sound:
- the number of bits used to record each measurement (sample resolution)
- the number of measurements taken per second (sample rate)
The sample rate affects the quality of the digital sample. This is because the more times an analogue sound wave is sampled, the more data is gathered. The more samples per second, the greater the file size will be of the digital audio.
Calculating file size of image and sound
Sound: sample rate(hertz)sample resolution(bits)length of file (sec)
Image: file size = image widthimage heightbit depth (bits)
DATA STORAGE UNITS
BIT
NIBBLE
BYTE
KIBIBYTE
MEBIBYTE
GIGIBYTE
TEBIBYTE
PETABYTE
EXBIBYTE
Compression
Compression involves applying an algorithm to a file in order to reduce the size of the file. Some file types apply no compression and are known as RAW files.
Benefits:
- reduce file size (save money? See picture)
- less bandwidth
- less time required to transfer and download files (NOT FASTER)
- real-time streaming of video and audio without buffering
Lossy compression
Lossy compression permanently removes some data from the original source file. The original file cannot be restored.
For example, in an image file, some pixels may be removed, and the computer then uses an algorithm (based on the compression technique) to ‘guess’ the removed content.
Compressing sound files removes sounds that are outside the human hearing range (mp3).
Benefits:
- Saves more storage speed than lossless
- In audio files is barely noticeable (sound outside human hearing range removed)
Disadvantages:
- The original file cannot be restored
- Image quality decrease can be very noticeable
Formats:
- Mp3, AAC, wma (sounds; btw midi is not actual recording of music but instructions on how to play that music thus not compressed)
- JPG/JPEG, GIF (Image)
Lossless compression
Lossless compression does not lose any data from the original file and the original file can be restored.
Run-length encoding (RLE):
- Uses an algorithm
- Finds groups of repeating data
- Stores them as a pattern
- Can be restored, no data is lost
(Works well with some images, but very well with text compression)
Dictionary encoding (mostly text as well):
- Uses an algorithm
- Creates index of data items
- (e.g. a value represents a word)
- Can be restored, no data is lost
Formats:
- flac (sound; btw wav is usually uncompressed)
- PNG, TIF (image)