Conversions

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

Conversions

Conversions are the process in which one number system is converted to another, for example denary to binary.

The two conversion methods mainly used are the Place value method and the Repeated division method, however the repeated divsion method only works when converting denary to any other number base

CraigNDave

https://www.youtube.com/watch?v=DoQV6wp35Gw&list=PLCiOXwirraUDGCeSoEPSN-e2o9exXdOka&index=5

Computer Science Tutor

https://www.youtube.com/watch?v=7LGgLi4vYsk&list=PL04uZ7242_M6O_6ITD6ncf7EonVHyBeCm&index=2

https://www.youtube.com/watch?v=wjTDHBSwNyc&list=PL04uZ7242_M6O_6ITD6ncf7EonVHyBeCm&index=3

Binary to Denary

Converting binary to denary is done using the place value method, to do this you need to know the binary number system. Binary system.jpg

To convert using the place value method you write out your binary number and starting from the far right digit, substitute its corresponding denary value in if the binary number is a 1 and don't substitute it in if it's a 0.

Then add up all of the denary values and you will have the converted denary value.

For example:

Column Value	 16  8  4   2   1 
Binary Number 	 1   0  1   0   1

You would then add up the denary numbers that were substituted.

So 10101 represents 16+4+1=21 so your denary value would be 21.

Denary to Binary

Place Value Method

In order to convert denary to binary with the place value method you need to split your denary number up into the binary system values that add up to total it, starting with the largest value that wouldn't cause the total to exceed the denary number

For example 50 would be broken down into 32,16 and 2, 64 isn't used even though its a larger value as it would cause the total to exceed 50.

You would then starting from the left place 1's and 0's in the appropriate columns for the used and unused numbers.

Column Value  32 16 8 4 2 1
Binary Number  1  1 0 0 1 0

Therefore the denary number 50 when converted to binary would read 110010.

Repeated Division Method

The repeated division method for denary to binary is done by taking the denary number you wish to convert and repeatedly dividing it by 2 as binary is base 2.

When you divide the denary number by 2 you write down the result and the remainder until the result is 0. The final 1 and the remainders are read starting from the bottom and going up.

Using 50 as an example again

50÷2 = 25 remainder 0
25÷2 = 12 remainder 1
12÷2 = 6 remainder 0
 6÷2 = 3 remainder 0
 3÷2 = 1 remainder 1
 1÷2 = 0 remainder 1

We then read the binary number bottom to top which gives us a final answer of 110010.

Hexadecimal to Denary

Converting hexadecimal to denary is done using the place value method, to do this you need to know the hexadecimal number system Hexidecimal Powers.jpg

The conversion method is the same as when converting denary to binary but you need to know the hexadecimal values.

To convert a hexidecimal number to denary, starting from the right you would multiply the hexadecimal number by its denary value from the hexadecimal number system.

The other method is to convert from hex to binary. Then from binary to denary. This will yield the same results but is more prone to mistakes and takes longer.

For example:

Converting for 2A9 to denary you would multiply, starting from the right, the 9 in the hexadecimal number by its corresponding denary value on the far right of the table 1, you would then multiply A by 16, substituting in A's value in hexadecimal which is 10 and then multiply 2 by 256.

So to convert 2A9 to denary you would do 2x256 + 10x16 + 9x1 = 681. Meaning 2A9 in denary would be 681

Denary to Hexadecimal

Place value method:

In order to convert denary to hexadecimal with the place value method, just like denary to binary you split up the denary number into the hexadecimal systen denary values that add up to it starting with the largest. However unlike denary to binary where you fit the largest value into the number once, when converting denary to hexadecimal you fit each value into the denary number as many times as possible.

For example: Converting 1000 from denary to hexadecimal.

You take the largest hexadecimal denary value that goes into it without exceeding it, 256, which can go into 100 3 times before exceeding it which gives us 3x256. We then take the next hexadecimal denary value 16 which can fit into the remaining 232 14 times giving us 14x16. The remaining final hexadecimal denary value 1, fits into the remaining 8, 8 times giving us 8x1

We then turn these values into their hexadecimal values and add them together, 3 and 8 remain as they are and 14 becomes its hexadecimal value E

so to convert 1000 from denary to hexadecimal we get 1000 = 3x256 + 14x16 + 8 = 3E8


Repeated Division Method:

This method is the same as it is for Denary to Binary except you divide by 16 each time instead of 2

You take your hexadecimal number and divide it by 16, writing down the result and the remainder. You keep diving the result and writing down the remainder until you reach 0. When this happens you read you remainders from bottom to top which gives you the numbers Hexadecimal value.

For example convert 12345 to hexadecimal:

12345÷16 = 771 remainder 9 771÷16 = 48 remainder 3 48÷16 = 3 remainder 0 3÷16 = 0 remainder 3

Reading the remainders from bottom to top gives us the hexadecimal number 3039.

Binary to Hexadecimal

The conversions between binary and hexadecimal are very similar, both conversions have you splitting up the number in order to convert it, as 4 binary digits can be represented by 1 hexadecimal digit.

To convert a Binary Number to a Hexadecimal number you need to split the binary number up into groups of 4 bits, starting from the right.

Example:

01011111

Split the number into 2 groups of 4. 0101 and 1111. Then use the place value method to get the hexadecimal equivalent of each group.

8 4 2 1

0 1 0 1 = 5

1 1 1 1 = 15 which in hexadecimal is F

so 01011111 in hexadecimal is 5F

Hexadecimal to Binary

This conversion is the exact same as Binary to Hexadecimal but reversed, each hexadecimal digit is written as a string of 4 binary numbers

Example:

A7

A = 10 = 8+0+2+0 = 1010

7 = 0+4+2+1 = 0111

so A7 as in binary is 10100111

Revision Questions

1. What is the denary value of the hexadecimal number E?

10
This would be 'A' in hexadecimal, A to F in hexadecimal represents 10 to 15 in denary.
15
This would be 'F' in hexadecimal, A to F in hexadecimal represents 10 to 15 in denary.
14
Correct
F
This is already a hexadecimal, you should convert E into denary (decimal).
A to F in hexadecimal represents 10 to 15 in denary.

2. What is the denary value of 1101?

16
The highest value is 15 in this case
13
Correct
12
This would be 1100 in binary
8
This would be 1000 in binary

3. What is the largest number possible in an 8 bit binary number?

255
If every column has a 1 in them the values add up to 255
1024
You would need more than 8 bits to represent this value, you would need 11 bits.
128
This is only 10000000 in binary

4. What is the hexadecimal value of the binary number 00111111?

4B
This would be 01001011 in hexadecimal. 4 = 4 = 0100 B = 11 = 1011
3F
Correct. 3 = 3 = 0011 F = 15 = 1111
F3
This would be 00111111 in hexadecimal. F = 15 = 1111 3 = 3 = 0011
63
This is the denary value, not hexadecimal.

5. What is the largest hexadecimal number that can be converted to 8 bit binary?

99
This would be 10011001 in binary, the answer should be 11111111 in hexadecimal.
B9
This would be 10111001 in binary, the answer should be 11111111 in hexadecimal.
F3
This would be 00111111 in binary, the answer should be 11111111 in hexadecimal.
FF
Correct. If all 8 binary columns have a 1 the values add up to 255.
The far right column has a value of 1, F = 15, so 15*1=15
The second from the right column has a value of 16, F = 15, so 15*16=240
If we do 15 + 240 = 255, which means that it is correct.

6. Convert A6 into binary.

→ A represents 10, so the first 4 units are 1010, the binary for 10.
→ 6 is 6, so the last 4 units are 0110.

7. Convert 10011110 into hexadecimal.

→ 1001 represents 9, which is 9 in hexadecimal.
→ 1110 represents 14, which is E in hexadecimal.

8. Convert the hexadecimal 24 into denary.

→ 2 is in the 16^1 unit, so you have 2*16^1, which equals 32
→ 4 is in the 16^0 unit, so you have 4*16^0, which equals 4
→ Then you add those two together, which adds to 36

9. Convert the hexadecimal 5BF into denary.

→ 5 is in the 16^2 unit, so you have 5*16^2, which equals 1280
→ B is in the 16^1 unit, so you have 11*16^1, which equals 176
→ F is in the 16^0 unit, so you have 15*16^0, which equals 15
→ Then you add all of those numbers together, which adds to 1471

10. Convert the denary number 68 into binary (8-bit).

→ 68 / 2 = 34 r 0
→ 34 / 2 = 17 r 0
→ 17 / 2 = 8 r 1
→ 8 / 2 = 4 r 0
→ 4 / 2 = 2 r 0
→ 2 / 2 = 1 r 0
→ 1 / 2 = 0 r 1
→ Arrange them from bottom to top to get the binary number 01000100.

Your score is 0 / 0