CONVERTING BETWEEN VALUES

You may be asked, for example, how many Mi are in a Ti. You don’t need to learn all

of the different numbers, just remember the patterns and the rule for dividing

numbers with powers:

numbers with powers Ti/Mi = 2^{40}/2^{20} = 2^{40-20}

Worked Example How many MiB are in a TiB?

How many MB are in 2 GB?

Step 1: write down the values for each.

^{3} = 1000 Step 3: you need 2 GB, so multiply by 2. 1000 × 2 = 2000 You can also give answer in the form of 2 x10^{3}

Step 1: write down the values for each.

Mib=2^{20} Tib=2^{40}

Step 2: work out the difference in powers. Subtract the smaller power (20) from the larger power (40) to get the new power. 40 – 20 = 20 The answer is 2 to the power of the difference in powers, 20. 2^{20} = 1 048 576

How many MB are in 2 GB?

Step 1: write down the values for each.

MB=10^{6} GB=10^{9}

Step 2: work out the difference in powers. 9 – 6 = 3, so 10These work in the same way. However, for a decimal number, these increase by a power

of 3 each time.

The decimal prefixes are the ones most commonly known and used in computing, e.g. a kilobyte (kB) is 1000 bytes, whereas a kibibyte (KiB) is 1024 bytes.

]]>Different quantities of bits can be described with specific names and prefixes. You should

know quite a few of these terms, but you also need to know what they represent.

■ At the very basic level you have bits, nibbles and bytes.

■ A bit is just 1 binary digit, e.g. 1 or 0.

■ A nibble is 4 bits, e.g. 0110 or 1101.

■ A byte is 8 bits (or 2 nibbles), e.g. 10101101 or 01011011.After a byte you start recording the number of bits in powers of 10.

The binary prefix for 2^{10} is Ki and it is called kibi.

the binary prefix for 2^{20} is Mi and stand for Mebi

The binary prefix for 2^{30} is Gi and stand for Gibi

The binary prefix for 2^{40}is Ti and stand for Tebi

These are called prefixes because they will all come before what they represent, which is

the number of bytes:

the number of bytes:

kibibytes= 2^{10} =1024 bytes

mebibytes= 2^{20}=1048576 bytes

gigibytes=2tebibytes=2^{40}=1099511627766 bytes

Using division, you can convert a base 10 (decimal) to both base 2 (binary) and base

16 (hexadecimal).

Convert 29_{10} to base 2 (binary).

■ Divide the number by the base you want it in until you get 0.

■ You want base 2 so you divide by 2.

Step 1: divide the number by 2.

29 ÷ 2 = 14 r 1

Step 2: take the quotient (the result) and divide it by 2.

14 ÷ 2 = 7 r 0

Step 3: repeat this process until you have 0 — quotient divided by 2.

7 ÷ 2 = 3 r 1

Still not 0? Repeat — quotient divided by 2.

3 ÷ 2 = 1 r 1

Still not 0? Repeat — quotient divided by 2.

1 ÷ 2 = 0 r 1

Make sure you write your remainder, as this will be used to make the answer.

Step 4: now you have 0, write all the remainders from the last to the first; 11101.

convert 100_{10} to binary (base 2)

Step 1: divide 100 by 2.

100 ÷ 2 = 50 r 0

Step 2: divide the quotient by 2.

50 ÷ 2 = 25 r 0

Step 3: repeat until you have 0.

25 ÷ 2 = 12 r 1

12 ÷ 2 = 6 r 0

6 ÷ 2 = 3 r 0

3 ÷ 2 = 1 r 1

1 ÷ 2 = 0 r 1

Continue dividing by 2 until you have 0.

Step 4: write all the remainders, from the last to the first, 1100100.

Convert 29_{10} to base 16 ( hexadecimal)

Step 1: divide the number by 16.

29 ÷ 16 = 1 r 13

Step 2: divide the quotient by 16.

1 ÷ 16 = 0 r 1

Step 3: repeat until you have 0.

Step 4: write the remainders, from the last to first; 1 13.

Step 5: check for numbers over 9. You can’t use the

number 13 in hexadecimal. You need to replace it with

the appropriate letter, D

1 13 becomes 1D

]]>29 ÷ 16 = 1 r 13

Step 2: divide the quotient by 16.

1 ÷ 16 = 0 r 1

Step 3: repeat until you have 0.

Step 4: write the remainders, from the last to first; 1 13.

Step 5: check for numbers over 9. You can’t use the

number 13 in hexadecimal. You need to replace it with

the appropriate letter, D

1 13 becomes 1D

a Convert the binary number 0101 to decimal.

Step 1: put the binary number into the table format as shown in Table

1 | Value | 1 | |

x base to the power 3 | x base to the power 2 | x base to the power 1 | x base to the power 0 |

Step 2: binary is base 2, so replace the word ‘base’ with 2.

1 | 1 | ||

x 2 to the power of 3 | x 2 to the power of 2 | x 2 to the power of 1 | x 2 to the power 0 |

Step 3 calculate each column

1 | Value | 1 | |

0 x 2 x2 x2 = 0 | 1 x2 x2 =4 | 0 x 2 =0 | 1x 1=1 |

Step 4: add the columns together.

0 + 4 + 0 + 1 = 5

0 + 4 + 0 + 1 = 5

Convert the hexadecimal number 1D9 to decimal.

Step 1: put the hexadecimal number into the table format as shown in Table

Step 1: put the hexadecimal number into the table format as shown in Table

1 | D | 9 |

x base to the power of 2 | x base to the power of 1 | x base to the power 0 |

Step 2: hexadecimal is base 16, so replace the word ‘base’ with 16.

1 | D | 9 |

x 16 to the power of 2 | x 16 to the power of 1 | x16 to the power 0 |

Step 3: calculate each column, replacing any letters with their numerical equivalent. (D = 13)

1 | D | 9 |

1x16x16 =256 | 13 x16=208 | 16x1=0 |

Step 4: add the columns together.

256 + 208 + 9 = 473

]]>256 + 208 + 9 = 473

Each digit in a number can be converted into its decimal (base 10) value using four steps as shown in the Worked examples that follow. Table shows how the digits are presented in table format. In computer science we start counting at 0. The first digit (on the right) is Digit 0 (D0). This is multiplied by its base to the power of 0 (base^{0}) .(D1) is multiplied by its base to the power of 1 (base^{1}) . Digit 2 (D2) is multiplied by its base to the power of 2 (base^{2}).

D4 | D3 | D2 | D1 | D0 |

x Base to the power of 4 | x Base to the power of 3 | x Base to the power of 2 | x Base to the power of 1 | x Base to the power of 0 |

Multiplying to the power of 2 means the number multiplied by itself, i.e. 4^{2} =4x4 Multiplying to the power of 3 means the number multiplied by itself, i.e. 4^{3} = 4x4x4

10 (known as decimal, or denary), there are 10 different symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

These symbols are then combined to represent any number, e.g. 12, 99, 386.

Binary is base 2 and there are two different symbols: 0 and 1.

Hexadecimal is base 16 and there are 16 different symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B,

C, D, E, F. Letters are used in hexadecimal instead of two-digit numbers.

A = 10

B = 11

C = 12

D = 13

E = 14

F = 15

The base of a number can be identified by its subscript:

■ If the subscript is 10, e.g. 910

, this means it is a base 10 number (decimal).

■ If the subscript is 2, e.g. 10112, this means it is a base 2 number (binary).

■ If the subscript is 16, e.g. 28116, this means it is a base 16 number (hexadecimal). ]]>

Worked examples

a) Find A, where A = {x | x ∈ ℤ ∧ x > –3}.

Step 1: understand the set comprehension statement. This is asking for all of the values of x, such

that x is a member of the set of integers AND x is larger than –3.

Step 2: integers are negative and positive whole numbers. Therefore integers larger than –3 are

–2, –1, 0, 1, 2, 3, 4 and so on. This set continues infinitely upwards.

Step 3: as the set shows a regular sequence, use the … notation to show that the values continue.

Therefore, A = {–2, –1, 0, 1, 2, 3, …}

b)If A = {7, 8, 9, 10} and B = {5, 6, 7, 8}, find:

i A ∪ B

The union of two sets includes the elements that are members of either set (or both). Be careful

not to repeat any elements. It may be helpful to think of this as joining the sets together and

removing any duplicates. A ∪ B = {5, 6, 7, 8, 9, 10}

ii A ∩ B

The intersection of two sets includes the elements that are members of both sets. A ∩ B = {7, 8}

iii A \ B

The difference of two sets is simply the elements that are in the first which are not in the second.

A \ B = {9, 10} ]]>

The main operations that can be carried out on sets are union, intersection, difference

and Cartesian product.

■ The union of sets A and B is the set of all elements that are a member of either or

both sets. The symbol ∪ is used to show union. If A = {1, 3, 7, 9} and B = {1, 2, 4, 7}

then A ∪ B = {1, 2, 3, 4, 7, 9}.

■ The intersection of sets A and B is the set of all elements that are members of both

sets. The symbol ∩ is used to show intersection. Using the same sets for A and B

above then A ∩ B = {1, 7}.

■ The difference of sets A and B is the set of all elements that are members of A but not

members of B. The symbol \ is used to show difference. Again using the same sets as

above, A \ B = {3, 9}.

■ The Cartesian product of two sets is the set of all possible ordered pairs between the

two sets. The symbol × (the same symbol that is used for multiplication) is used to

denote a cartesian product. For example, if A = {1, 7} and B = {True, False} then

A × B = {(1, True), (1, False), (7, True), (7, False)}. ]]>

A subset is defined as a set that is wholly contained within another set. For example,

if A = {1, 2, 3, 4} and B = {2, 3} then B is a subset of A. The symbol ⊆ is used

to mean subset, so B ⊆ A reads ‘B is a subset of A’. The line in this symbol is

reminiscent of an equals sign because a subset can technically have exactly the same

elements as the superset. That is, if D = {1, 2, 3, 4} and E = {1, 2, 3, 4}, D = E and

D ⊆ E are both true.

A proper subset uses the symbol ⊂ and is defined as a subset where at least one element

is in the superset that is not in the subset. For example, {1, 2, 3} is a proper subset of ℕ

because there is at least one element in ℕ that is not in {1, 2, 3}. ]]>