How different data is stored inside the computer as bit patterns
How different data is stored inside the computer as bit patterns
All data inside a computer is conveyed as a sequence of electrical signals that are either on or
off. As a result, in order for a computer to process any type of data, including text, graphics,
and music, it must first be transformed to binary form. If the data is not transformed into
binary - a series of 1s and 0s - the computer will simply not understand or process it.
Representing text
When a key on a keyboard is pressed, it must be transformed into a binary number so that the
computer can process it and display the written letter on the screen.
Text can be converted into binary using a code in which each number represents a character.
ASCII is one coding we can use for this. The ASCII code assigns a binary number to each
character on the keyboard. As an example:
the letter ‘a’ has the binary number 0110 0001 (this is the denary number 97)
the letter ‘b’ has the binary number 0110 0010 (this is the denary number 98)
the letter ‘c’ has the binary number 0110 0011 (this is the denary number 99)
Text characters in the ASCII code begin at denary number 0, however this includes special
characters such as punctuation, the return key, and control characters, as well as the number
keys, capital letters, and lower case letters.
ASCII code can only contain 128 characters, which is sufficient for most English words but
insufficient for other languages. More characters are required to apply accents in European
languages or larger alphabets such as Cyrillic (the Russian alphabet) and Chinese Mandarin.
As a result, another code known as Unicode was developed. This meant that people speaking
different languages could use computers.
Representing images
Images must also be converted into binary in order for a computer to process them and
display them on our screen. Pixels are the building blocks of digital images. Binary numbers
make up each pixel in an image.
If we state that 1 is black (or on) and 0 is white (or off), then we can use binary to build a
simple black and white image.
To make the image, a grid can be drawn and the squares colored (1 – black and 0 – white).
However, before the grid can be built, the size of the grid must be determined. This
information is known as metadata, and computers rely on it to determine the size of an image.
If the image's metadata is 10x10, it says the image will be 10 pixels across and 10 pixels
down.
This is an example of an image made in this manner:
Adding colour
The approach described so far is adequate for black and white photographs, but most images
require color as well. Instead of only 0 and 1, employing four potential numbers allows an
artwork to use four different colors. In binary, this is represented by two bits per pixel:
00 – white
01 – blue
10 – green
11 – red
While this is still a limited color palette, adding another binary digit doubles the number of
colors available:
1 bit per pixel (0 or 1): two possible colours
2 bits per pixel (00 to 11): four possible colours
3 bits per pixel (000 to 111): eight possible colours
4 bits per pixel (0000 – 1111): 16 possible colours
…
16 bits per pixel (0000 0000 0000 0000 – 1111 1111 1111 1111): over 65 000
possible colours
The colour depth refers to the number of bits utilized to store each pixel. Additional pixels
are required to store each available color in images with more colors. This means that
photographs with a lot of colors require larger files.
Image quality
The resolution of the image influences image quality. The resolution of an image describes
how closely packed the pixels are.
The pixels in a low-resolution image are larger, thus fewer are required to fill the space. This
produces visuals that appear blocky or pixelated. Because a high-resolution image has more
pixels, it appears much better when zoomed in or stretched. The disadvantage of having more
pixels is that the file size will be larger.
Representing sound
Sound must be translated into binary before computers can process it. To accomplish this,
sound is recorded - typically with a microphone - and transformed into a digital stream.
A sound wave is sampled at regular time intervals using an analogue to digital converter. A
sound wave like this, for example, can be sampled at each time sample point:
After that, the samples can be transformed to binary. They'll be rounded up to the next whole
number.
When the time samples are plotted again onto the same graph, the sound wave appears to
have changed. This is because sampling does not account for what the sound wave is doing
between samples.
As a result of the data loss between the time samples, the sound loses quality. To improve the
quality and store the sound at a higher quality than the original, use more time samples that
are closer together. More detail about the sound may be collected this way, so that when it is
converted to digital and back to analogue, it does not lose as much quality.
The sample rate is the frequency at which samples are taken and is measured in Hertz (Hz).
One sample per second is one hertz (Hz). The majority of CD-quality audio is sampled at
44100 or 48000 KHz.