0% found this document useful (0 votes)
45 views14 pages

Binary

Uploaded by

Opera GX
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views14 pages

Binary

Uploaded by

Opera GX
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Units

In a computer, all data is stored in binary form. A binary digit has two


possible states, 1 and 0.

A binary digit is known as a bit. A bit is the smallest unit of data a


computer can use. The binary unit system is used to describe bigger numbers
too.

Eight bits are known as a byte.

The binary unit system is as follows:

Size Unit

8 bits 1 byte (B)

1,000 bytes (1,000 B) 1 kilobyte (KB)

1,000 kilobytes (1,000 KB) 1 megabyte (MB)

1,000 megabytes (1,000 MB) 1 gigabyte (GB)

1,000 gigabytes (1,000 GB) 1 terabyte (TB)

1,000 terabytes (1,000 TB) 1 petabyte (PB)

Binary and denary


Humans tend to use the denary number system. However, computers work
in binary. Denary numbers must be converted into their binary equivalent
before a computer can use them.
The denary system has ten digits (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9). Each
denary place value is calculated by multiplying the previous place value by ten.
For example:

10,000 1,000 100 10 1

So, the value of the number 124 in denary place values is actually:

Place value 10,000 1,000 100 10 1

R/ 0 0 1 2 4

This gives (1 × 100) + (2 × 10) + (1 × 4) = 124

Binary to denary

Binary has just two units, 0 and 1. The value of each binary place value is
calculated by multiplying the previous place value by two. The first eight
binary place values are:

128 64 32 16 8 4 2 1

In binary, each place value can only be represented by 1 or a 0.

To convert binary to denary, simply take each place value that has a 1, and
add them together.

Example - binary number 1111100

128 64 32 16 8 4 2 1

0 1 1 1 1 1 0 0

Result: (0 × 128) + (1 × 64) + (1 × 32) + (1 × 16) + (1 × 8) + (1 × 4)


+ (0 × 2) + (0 × 1) = 124

Denary to binary

To convert from denary to binary, start by subtracting the biggest place


value you can from the denary number, then place a 1 in that place value
column. Next, subtract the second biggest place value you can, and place a 1
in the column. Repeat this process until you reach zero. Finally, place a 0 in
any empty place value columns.

Example - denary number 84

First set up the columns of binary place values.

128 64 32 16 8 4 2 1

64 is the biggest place value that can be subtracted from 84. Place a 1 in
the 64-place value column and subtract 64 from 84, which gives 20.

128 64 32 16 8 4 2 1

16 is the biggest place value that can be subtracted from 20. Place a 1 in
the 16-place value column and subtract 16 from 20, which gives 4.

128 64 32 16 8 4 2 1

1 1

4 is the biggest place value that can be subtracted from 4. Place a 1 in the
4-place value column and subtract 4 from 4, which gives 0.

128 64 32 16 8 4 2 1

1 1 1

Place a 0 in each remaining empty place value column.

128 64 32 16 8 4 2 1

0 1 0 1 0 1 0 0

Result: 84 in denary is 1010100 in binary.

To check that this is right, convert the binary back to denary:


(0 × 128) + (1 × 64) + (0 × 32) + (1 × 16) + (0 × 8) + (1 × 4) + (0 ×
2) + (0 × 1) = 84

Another way to convert a denary number to binary is to divide the starting


number by two. If it divides evenly, the binary digit is 0. If it does not and
there is a remainder, the binary digit is 1. Finally, reverse the digits and you
have the correct number.

Binary addition
When two numbers are added together in denary, we take the first number,
add the second number to it, and get an answer. For example, 1 + 2 = 3.

When we add two binary numbers together the process is different.

There are four rules that need to be followed when adding two binary
numbers. These are:

0 + 0 = 0

1 + 0 = 1

 1 + 1 = 10 (binary for denary 2)

 1 + 1 + 1 = 11 (binary for denary 3)

Example - adding 01 + 10

1 + 0 = 1

0 + 1 = 1

Result in binary: 11 (which is denary 3)

Example - adding 01 + 101

1 + 1 = 0, carry 1

1 + 0 + 0 = 1

0 + 1 = 1
Result in binary: 110 (which is denary 6)

Example - adding 01010011 + 01110110

1 + 0 = 1

1 + 1 = 0, carry 1

1 + 0 + 1 = 0, carry 1

1 + 0 + 0 = 1

1 + 1 = 0, carry 1

1 + 0 + 1 = 0, carry 1

1 + 1 + 1 = 1, carry 1

1 + 0 + 0 = 1

Result in binary: 11001001 (which is denary 201). You can check your
answers by converting each binary number into denary and checking your
addition. In this example, 01010011 is 83 in denary and 01110110 is 118 in
denary. So, 83 + 118 is 201.

Overflow

Overflow occurs when the result of a calculation requires more bits (place
values) than are in the available range.

For example, when using eight bits, the largest number that can be recorded
is 11111111 (denary 255). When adding together two eight-bit numbers, a
situation may occur when the result requires more than eight bits to hold it.
For example, adding the binary numbers 11111110 (denary 254) and
00000010 (denary 2) would give:
The result is 10000000 (denary 256), which requires nine bits. However, as
only eight bits are available to hold the number, the result would be
00000000 (denary 0).

As you can see, overflow can have serious consequences for the validity of
calculations.

Consider a simple black and white image. If 1 is black (or on) and 0 is white
(or off), then a simple black and white picture can be created using binary.

To create the picture, a grid can be set out and the squares, known as
pixels, coloured (0 - black and 1 - white):

Colour depth

Many images need to use colours. To add colour, more bits are required for
each pixel. The number of bits determines the range of colours. This is known
as an image's colour depth.

For example, using a colour depth of two, ie two bits per pixel, would allow
four possible colours, such as:

 00 - black

 01 - dark grey

 10 - light grey

 11 - white

Each extra bit doubles the range of colours that are available:

 one bit per pixel (0 or 1) - two possible colours

 two bits per pixel (00 to 11) - four possible colours

 three bits per pixel (000 to 111) - eight possible colours

 four bits per pixel (0000 to 1111) - 16 possible colours

 16 bits per pixel (0000 0000 0000 0000 to 1111 1111 1111 1111) - over
65,000 possible colours
The more colours an image requires, the more bits per pixel are needed.
Therefore, the more the colour depth, the larger the image file will be.

Colour depth is the range of colours available.

Image size

Image size is simply the number of pixels that an image contains. It is


expressed as height and width. For example:

 256 × 256

 640 × 480

 1024 × 764

Image file size

The size of an image file can be estimated using:

 the image height in pixels

 the image width in pixels

 the colour depth per pixel

Example - an image of height 200, width 400, colour depth 16 bits

200 × 400 = 80,000

80,000 × 16 = 1,280,000 bits

1,280,000 bits ÷ 8 = 160,000 bytes

160,000 ÷ 1000 = 160 kilobytes

Result: 160KB

Resolution

Image quality is affected by the resolution of the image. The resolution of an


image is a way of describing how tightly packed the pixels are.

In a low-resolution image, the pixels are larger and therefore, fewer are
needed to fill the space. This results in images that look blocky or pixelated.
An image with a high resolution has more pixels, so it looks a lot better
when it is enlarged or stretched. The higher the resolution of an image, the
larger its file size will be.

Metadata

Files contain extra data called metadata. Metadata includes data about the
file itself, such as:

 file type

 date created

 author

An image file also includes metadata about the image data itself, such as:

 the height and width of the image - this defines how many rows and columns
the pixels are to be arranged in

 the resolution

 the colour depth

Without this metadata, the image data would not be correctly interpreted,
meaning the image could not be correctly displayed.
Answer

Answer

Answer

You might also like