Number systems part 2

In part 1 I showed you how to convert between binary and decimal now I will show you how to do the same but with octal and hexadecimal.

 

Lets start by converting from decimal

From decimal and binary

The easiest way to do this is to convert to binary first as shown in part 1.

Using 23 again we end up with in binary 010111

For octal we break the binary number into segments of three.

010-111

Now for each segment we convert it into octal like we did to convert binary to decimal, but as we are only using three digits the highest decimal number we can reach is 7.

010 = 0 + 2 + 0 = 2

111 = 4 + 2 + 1 = 7

Our octal number is 27

Now we will do the same with hexadecimal which uses segments of four which makes the highest decimal number we can reach 15 or F in hex.

0001-0111

0001 = 0 + 0 + 1 = 1

0111 = 0 + 4 + 2 + 1 = 7

Our hexadecimal number is 17

To decimal and binary

This is just a matter of reversing what we did above.

Starting with the octal number 27 we will convert the 2 then the 7 into binary.

2 – 4 = cant (0)

2 – 2 = 0 (1)

0 – 1 = cant (0)

010

7 – 4 = 3 (1)

3 – 2 = 1 (1)

1 – 1 = 0 (1)

111

binary: 010111

With the hexadecimal number 17 we will convert the 1 then the 7 into binary.

1 – 8 = cant (0)

1 – 4 = cant (0)

1 – 2 = cant (0)

1 – 1 = 0(1)

0001

7 – 8 = cant (0)

7 – 4 = 3 (1)

3 – 2 = 1 (1)

1 – 1 = 0 (1)

0111

binary: 00010111

To then convert the binary to decimal see part 1

 

If you want to take your knowledge of number systems further you may want to look into doing maths with binary or hexadecimal.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s