You are on page 1of 11

1.1.

1 Binary systems
In mathematics and digital electronics, a binary number is a number expressed in
the binary numeral system, or base-2 numeral system, which represents numeric
values using two different symbols: typically 0 (zero) and 1 (one). More
specifically, the usual base-2 system is a positional notation with a radix of 2.
Because of its straightforward implementation in digital electronic
circuitry using logic gates, the binary system is used internally by almost all
modern computers and computer-based devices such as mobile phones. Each digit
is referred to as a bit.
Calculating binary numbers
Likewise, when working with binary numbers, the position is important in order for
you to be able to calculate the correct value.
The value 1 in binary represents the value one, the value 0 represents zero.
For base-two binary numbers, you need to multiply each digit on the left by a
progressive factor of 2. As with denary numbers, the calculations always work from
right to left.

in
sa
Example 1: Denary = 1
us
H
128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 1
q a
ht

Answer: Binary = 00000001


us

(1 * 1) = 1
-M
M

Example 2: Denary = 3

128 64 32 16 8 4 2 1
0 0 0 0 0 0 1 1

Answer: Binary = 00000011

(1 * 1) + (2 * 1) = 3

Contact the teacher: 03215275281


Example 3: Denary = 6

128 64 32 16 8 4 2 1
0 0 0 0 0 1 1 0

Answer: Binary = 00000110

(1 * 0) + (2 * 1) + ( 4 * 1) = 6

Example 4: Denary = 12

128 64 32 16 8 4 2 1
0 0 0 0 1 1 0 0

in
Answer: Binary = 00001100

sa
(1 * 0) + (2 * 0) + (4 * 1) + (8 * 1) = 12

us
H
Example 5: Denary = 37
a q

128 64 32 16 8 4 2 1
ht

0 0 1 0 0 1 0 1
us

Answer: Binary = 00100101


-M

(1 * 1) + (2 * 0) + (4 * 1) + (8 * 0) + (16 * 0) + (32 * 1) = 37
M

Example 6: Denary = 115

128 64 32 16 8 4 2 1
0 1 1 1 0 0 1 1

Answer: Binary = 01110011

(1 * 1) + (2 * 1) + (4 * 0) + (8 * 0) + (16 * 1) + (32 * 1) + (64 * 1) = 115

Contact the teacher: 03215275281


Example 7: Denary = 255

128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1

Answer: Binary = 11111111 (the maximum 8 digit binary number)

(1 * 1) + (2 * 1) + (4 * 1) + (8 * 1) + (16 * 1) + (32 * 1) + (64 * 1) = 255

if the digit is a 0 then just don't add that value to the total. The number below has a 0 in the 32
position and the binary number in decimal is:

11011111
1x128 + 1x64 + 0x32 + 1x16 + 1x8 + 1x4 + 1x2 + 1x1 = 223 decimal

in
Let's try a smaller binary number:

sa
What is 10101 in decimal?

Answer: us
H
10101
q
1x16 + 0x8 + 1x4 + 0x2 + 1x1 = 21 decimal
a
ht
us
-M
M

Contact the teacher: 03215275281


Bit

A 'bit' (short for Binary Digit) is the smallest unit of data that can be stored by a computer. Each
'bit' is represented as a binary number, either 1 (true) or 0 (false).

Byte

A 'byte' contains 8 bits, so for example, it could be stored as 11101001.

A single keyboard character that you type, such as the letter A or the letter T takes up one byte of
storage.

Nibble

This is not a very commonly used term compared to bit and byte. It is the term given to a group
of four bits. Therefore two nibbles make a byte.

The reason it is not very common is because most microprocessors use groups of 8 bits and

in
higher i.e. they use one or more bytes to process data. Not many devices make use of a nibble.

sa
Kilobyte

us
H
a q
ht
us
-M
M

A kilobyte is a unit of storage capacity. It can be written as kB or kbyte.

A kilobyte is generally thought of as 1,000 bytes. However, to be completely correct, it is


actually 1,024 bytes which is 2 to the power of 10.

This would be equivalent to 1024 characters on the screen.

Contact the teacher: 03215275281


Images usually take up more storage space than text characters. The images below will help you
put storage sizes into context.

Storage size = 7 kilobytes Storage size = 33 kilobytes

in
So a simple, limited colour image as seen on the left will take up much less storage than the

sa
detailed (but cute) image on the right.

Megabyte
us
H
A megabyte is a unit of storage capacity. It can be written as MB or mbyte.
a q

A Megabyte is generally thought of as one million bytes or 1,000 kilobytes. However, to be


ht

completely correct, it is actually 1,048,576 bytes or 1,024 kilobytes.


us

PowerPoint presentations on the other hand can be quite large. For example, a ten slide
presentation with an image on each slide and a theme applied to the slide backgrounds could be 2
-M

or 3 megabytes in size.
M

A typical MP3 song can be anywhere between 3 to 5 megabytes in size.

A CD can store up to 650 megabytes of data.

. Gigabyte

A Gigabyte is equivalent to 1024 Megabytes although you will commonly see it referred to as
1,000 Megabytes (which isn't correct).

It can be written as GB or gbyte, but not Gb (used for gigabit).

1 Gigabyte could hold the contents of about 10 yards of books on a book shelf.

A DVD can store a Hollywood blockbuster film which would be around 4-8 gigabytes in size.

Hard disks are measured in gigabytes, with a typical hard disk size being around 160 gigabytes
or more.

Contact the teacher: 03215275281


Terabyte

Commonly written as TB.

A terabyte is equivalent to 1024 Gigabytes although you will commonly see it referred to as
1,000 Gigabytes (which isn't correct).

1.1.2 Hexadecimal numbers

This is name given to numbers using the base-16 notation.

Allowed Hexadecimal digits are:

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

in
The decimal numbers 10 to 15 are represented with the letters A to F. There are 16 values, hence
why it is a base-16 number system.

sa
Hexadecimal is widely used in computing because it is a much shorter way of representing a byte
us
of data. If we were to represent a byte of data in binary, it would require 8 digits, e.g. 11111111.
H
However, that same byte of data could be represented in hexadecimal in just two digits e.g. FF -
much more compact and user friendly than a binary number.
a q
ht

The table above only shows hexadecimal numbers up to denary 15. The largest byte value is 255
and you can use hexadecimal numbers to represent up to this value.
us

We can extend the table above to show the next set of hexadecimal numbers:
-M

Decimal 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
M

Hexadecimal 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F

Once we have gone past the first 16 numbers, a 1 is added in front of the next 16 numbers
(similar to denary when we go from 0-9 and then the next 10 numbers have a 1 in front of them)

The next set of hexadecimal numbers would have a 2 in front of them:

Decimal 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
Hexadecimal 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F

See if you can complete the table for the next set:

Decimal 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

Hexadecimal

Contact the teacher: 03215275281


Hexa to decimal
HEX 0 1 2 3 4 5 6 7 8 9 A B C D E F
DEC 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Here is a HEX number: 1E5DF


To convert this to a DEC, we need to define the base for our power function. Since
HEX is based on 16 different digits [0-9A-F], our base is 16.

To convert from HEX to DEC, follow these steps:

We know that F = 15 in DEC so we use this formula (15*160) = 15


We know that D = 13 in DEC so we use this formula (13*161) = 208
We know that 5 = 5 in DEC so we use this formula (5*162) = 1280
We know that E = 14 in DEC so we use this formula (14*163) = 57344
We know that 1 = 1 in DEC so we use this formula (1*164) = 65536

in
Now we add all of the numbers together to get the DEC number for HEX number

sa
1E5DF:
15 + 208 + 1280 + 57344 + 65536 = 124383

us
H
Hexa to binary
a q

Example #1
ht

Convert (4E)16 to binary:


(4)16 = (0100)2
us

(E)16 = (1110)2
-M

So
(4E)16 = (01001110)2
M

Example #2
Convert (4A01)16 to binary:
(4)16 = (0100)2
(A)16 = (1010)2
(0)16 = (0000)2
(1)16 = (0001)2
So
(4A01)16 = (0100101000000001)2

Contact the teacher: 03215275281


Uses of hexadecimal in computing

Here are two important aspects to the beauty of using Hexadecimal with
computers: First, it can represent 16-bit words in only four Hex digits, or 8-
bit bytes in just two; thus, by using a numeration with more symbols, it is
both easier to work with (saving paper and screen space) and makes it
possible to understand. This is why programs such as DEBUG, use only
Hexadecimal to display the actual Binary bytes of a Memory Dump rather
than a huge number of ones and zeros!

The second aspect is closely related: Whenever it is necessary to convert the


Hex representation back into the actual Binary bits, the process is simple
enough to be done in your own mind. For example, FAD7 hex is
1111101011010111 (F=1111, A=1010, D=1101, 7=0111) in Binary.

A common use of hexadecimal numbers is to describe colors on web pages.


Each of the three primary colors (i.e., red, green and blue) is represented by

in
two hexadecimal digits to create 255 possible values, thus resulting in more
than 16 million possible colors. For example, the HTML (hypertext markup

sa
language) code telling a browser to render the background color of a web

us
page as red is <body bgcolor="#FF0000"> and that telling it to render the
page as white is <body bgcolor="#FFFFFF">.
H
MAC addresses consist of hex values, and a Media Access Control (MAC)
q

address looks like this:


a
ht

Af-14-b3-c2-14-45
us

The first oddity with MAC addresses is that we've got numbers and letters in
-M

the address. Since every single networking device should have a unique MAC
address, we have to use hex rather than the usual decimals we're all familiar
with. Using hex to express an address allows us to have many more possible
M

combinations than we'd have if we just used decimals.

Contact the teacher: 03215275281


1.1.2 Data storage

Understanding different formats to store sound, pictures, video, text


and numbers

1 Plain text (.txt). In this case, the individual characters in the document
(letters, punctuation, newlines etc.) are each encoded into bytes using
the ASCII encoding, and stored in a simple sequence. This format only
stores the text itself, with no information about formatting, fonts, page
size, or anything like that. It is portable across all Computer systems
and can be read and modified by a huge range of software applications.
The details of the format are freely available and standardized. If the
storage media are damaged, any undamaged sections can be recovered
without problems.
2 Word document (.doc). In this case the text plus formatting, page size
and so on is stored in a complex encoding.
3 PDF (Portable Document Format, .pdf). In this case, the text plus

in
formatting, page size and similar information are stored in a moderately
complex encoding. While the details of this encoding are freely available,

sa
the format is owned by Adobe and can be changed by them at any time,

us
for any reason. The document can be viewed and printed on all major
platforms, using free software provided by Adobe (or others). PDF
H
documents cannot be readily edited.
4 HTML (Hypertext Markup Language, .html). The text, plus simple
q

formatting, is stored in a simple encoding .This format is freely available


a

and controlled by a public-interest standards body. The document can be


ht

viewed in any web browser. It can be edited in a text editor by someone


us

who knows HTML, or in any number of rich text editors, word


processors, HTML editors and so on.
-M

5 An image format such as JPEG (.jpg) or TIFF. While the image can be
viewed on any modern platform using a wide range of software, editing
the content of the document (the sequence of characters, words etc.)
M

will be extremely cumbersome. This format preserves appearance but


loses all structure. However this may be an option for documents that
only exist on paper, perhaps with a plan to use optical character
recognition (OCR) to migrate to a text-based format in the future.

Binary Representation of Bitmap Images

All bitmap images are stored as an array of pixels. A monochrome bitmap


will store a 1 for a black pixel and 0 for a white pixel (or vice-versa
depending on the encoding protocol).

Contact the teacher: 03215275281


This image could be represented by the

following 35 binary digits (5 bytes):

00100 01010 01010 10001 11111 10001 00000

It would also be necessary to store the


dimensions of the image.

If the image were in colour, using a colour


palette of 256 possible shades, each pixel would
need to translate to a value between 0 and 256
(8 bits). Thus we would need 35 bytes to store
the image. It is common for colours to be
recorded by quantity or Red, Green and Blue
(RGB) and this is stored using 3 bytes per pixel so we would need 105
bytes to store the image. Bitmap images can be encoded in order to reduce

in
the file size. Examples of encoded bitmaps in clued JPG, PNG and GIF file
types.

sa
Binary Representation of Sound
us
In order to digital record sound, a microphone is used, a device that
H
converts the analogue sound into a digital form by altering the output signal
from the device. In order to store this digitally, the voltage is sampled at
q

frequent intervals (typically 48 000 times per second or 48kHz) and stored
a

as a binary code (typically 16 or 32 bits per sample).


ht
us
-M
M

This equates to slightly over 1.5 million bits per second, or 88 MB per
minute. An 80 minute album stored in such a manner would require 6.9 GB
of storage. There are three ways of altering this:
Sample Rate: By reducing the sample rate (e.g. to 22 kHz), you reduce the
amount of data you need to store. This has quite serious effects on the
quality of the audio.

Contact the teacher: 03215275281


Sample Depth:Much as with colour, you can reduce the precision of each
datum,using only 8 bits per sample instead of 32, for example.

Compression: Ideally you would sample at the highest practical rate you can
and these use an encoding algorithm to reduce the output file size (this is
why Audacity projects are much bigger in size than the files output). This
can be Lossless compression (e.g. FLAC [and potentially MP3/AAC/Ogg
Vorbis files]) or Lossy compression (e.g. most MP3, AAC and Ogg Vorbis
files). WAV and AIFF files are used for storing uncompressed audio.

in
sa
us
H
a q
ht
us
-M
M

Contact the teacher: 03215275281

You might also like