# How to convert decimal to binary

In this section I will look at converting
decimals to binary, hexadecimal and also look at the operation called “and”. These skills
are important to learn when you start dealing with IP addresses. If you career starts taking
you more towards the networking side of things, understanding how to convert numbers between
different formats becomes essential to creating and managing a network.
In computing you have switches which can either be set to on or off. This gives you 2 possible
values. To allow you to represent larger numbers computers group these switches together. The
most common one you will deal with is a byte which is 8 bits. A byte has a value of 0 to
255. To convert a decimal to a binary I use the
following table. Each bit in the table has a value assigned to it. You can see, going
from right to left the first value has a 1 in the first position. The second position
has a value of 2. Twice the previous value. The 3 position has a value of 4. As you can
see the value doubles in each position until the final value of 128.
If I take a random number, say 174 and wanted to convert it into binary I would do the following.
First I would go to bit 8 and work out if 174 is greater or equal to 128. If 174 is
greater than 128, which it is, the result is a 1. I would than subtract 128 from 174
and place the result, 46 in the next column. The next column has a value of 64.
46 is not greater than 64 so the result is no and gets a value of 0. I now move 46 to
the next column and compare it with its value of 32. 46 is greater than 32 so I place a
one in this column and subtract 32 from 46 to give me 14. I keep following the same procedure
throughout the table. You will notice that when I get to the second
last column the value 2 equals the column value. In this case the value is equal to
the column value and thus the result is still a one. All columns after this will equal zero
since there is no remainder to subtract from the column value. This gives us a binary value
of 1 0 1 0 1 1 1 0. Using this method you can quickly and easily covert any decimal
number into a binary number. With IP version 6, hexadecimal is used in
the IP address so you need to have an understanding of it in order to master IP version 6. If
I were to take an IP version 4 address and convert to hexadecimal I would do the following.
First of all I would convert the numbers into binary using the previously shown method.
Once the numbers are in binary they are easier to work with. The next step is to divide the
binary into groups of four. Dividing the bits up like this gives each group of 4 bits 16
different possible values. Hexadecimal uses 16 values and thus that is where hexadecimal
gets it’s name from. It is a simple matter to convert these values into decimal values.
As you can see each group of 4 bits has been given a value between 0 and 15. Once you have
this value you can use this table to determine the hexadecimal value. As you can see the
first value 12 and gets a value of C. Values between 0 and 9 get the same value so therefore
the values in the example 0, 9, 1, 1 and 3 all get the same values.
It is not till we get to far right you see the value 14 will get the value of E and the
value 10 will get the value of A. Certain IP version 6 addresses have IP version 4 addresses
imbedded in them. It is important to understand how to covert decimal to hexadecimal to understand
IP version 6 addresses. Slide 4
Once you start working with more than one network, it is important to understand how
the “and” operator works. Consider this table. When comparing two bits, if both bits
are 1 the result is a one. You will notice that in all other cases the results is zero.
All it takes is one or both bits to be zero and the result it zero. If you have trouble
understanding this, think of the “and” operator as a multiplication operator instead.
1 times 1 is 1. 1 times 0 is 0. 0 times 1 is 0 and 0 times 0 is 0.
Why is the “and” operator important? Later in the course you will learn the “and”
operator is used to determine the destination of a packet. Consider this small network.
If a computer sends data over the network to a server, the computer needs to determine
if the data is to be sent directly to the server or the data needs to be sent via a
router. If the server is on the same network as the
client it sends it directly to the server. If the server is on anther network the client
computer sends the data to a router. By using the “and” operator, your computer can
work out where to send the data. Later on in the course this process will be explained
in more detail. This has been a short induction to converting
decimals. If you don’t work a great deal with the networking side, you may want to
consider using the windows calculator to convert decimals to hexadecimal and binary for you.
Just remember to switch the calculator to scientific mode first. Before sitting for
your exam, check the exam requirements. A lot of the exams will allow you to use the
windows calculator in the exam. If you are planning to sit any Cisco exams, you need
to have an excellent understanding of how to covert decimals.
Cisco don’t give you a calculator in the exam to help you and believe me you need to
do the math fast. Lastly if you need more practice there are a lots of resources on
the internet. When I was first learning networking I used a web site called learn to subnet dot
com. This is a great little site that will help
you understand how to convert decimals to binary and also how to subnet. I will cover
subnetting in more detail later in the course so don’t worry if you don’t understand
it yet. For the present just make sure you understand the basics of binary and hexadecimal.
If you don’t understand how to covert values you can also cheat for the moment and use
the windows calculator.

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 