Vous êtes sur la page 1sur 7

Binary-to-decimal conversion

Written by Admin at Happy Router.com


Thursday, 15 June !!"
Binary-to-decimal conversion
To be a net#or$ en%ineer &especially a ''(A), you need to understand binary so that you can
understand ho# a net#or$ device uses its *+ address, subnet mas$, and de,ault %ate#ay
in,ormation. -ou also need to be able to convert ,rom binary to decimal and ,rom decimal to
binary.
What is binary and ho# can it help you as a net#or$ en%ineer. /et0s ,ind out...
Binary-to-decimal conversion
The following article was originally published on SearchNetworking.com
<!--[if !vml]--><!--[endif]-->
To be a network engineer, you need to understand binary so that you can understand how a
network device uses its I address, subnet mask, and default gateway information! "ou also
need to be able to convert from binary to decimal and from decimal to binary!
What is binary.
Binary is a numberin% system that uses only the di%its 1 and !. We are accustomed to usin% the
decimal number system, #hich uses the di%its ! throu%h 1.
Binary is the numberin% system that net#or$ devices use to process all data. Without binary,
computers and net#or$s #ould not ,unction. All data sent across a net#or$ is in binary.
Just li$e #e use the decimal numberin% system &numbers ! throu%h 1) ,or all countin%, money,
and ,inancial transactions, computers use binary ,or stora%e o, all data, all data transmissions,
and all numerical calculations. -ou can thin$ o, this as a lan%ua%e. 2or e3ample, all people in
Russia use Russian ,or all communication. *, someone in Russia tal$ed to someone in the 4nited
5tates, they #ould probably tal$ in 6n%lish so that #e could understand and communicate. That
person #ould be bilin%ual because they understand t#o lan%ua%es. *n that sense, you could
compare the computer to them because the computer understands t#o numberin% systems,
binary and decimal. Humans don0t #ant to have to thin$ or do calculations in binary. We #ant to
convert those binary numbers to decimal. 'onvertin% ,rom binary to decimal is not di,,icult. The
numbers ! and 1 in binary are converted to ! and 1 in decimal. A,ter that, it %ets a little more
complicated.
Here is an e3ample o, countin% ,rom 7ero to ten usin% binary8
#ecimal $inary
% %
& &
' &%
( &&
) &%%
* &%&
+ &&%
, &&&
- &%%%
. &%%&
&% &%&%
All binary to decimal or decimal to binary conversions use this chart8
'
,
'
+
'
*
'
)
'
(
'
'
'
&
'
%
&'- +) (' &+ - ) ' &

/et0s discuss ho# to use this chart. 2irst, al#ays start by loo$in% at the chart ,rom ri%ht to le,t,
not ,rom le,t to ri%ht. 5econd, all the numbers on the chart stay #here they are -- you don0t
chan%e these. These numbers are used to tell you the values o, the binary di%its you #ill enter
in the blan$s.
2inally, the top line o,
3
numbers tells you #hat each column represents. The column on the ,ar
ri%ht is #orth
!
. The second line, #ith the decimal numbers, tells you #hat the ans#er is to the

!
line. 5o, i, you loo$ at the column on the ,ar ri%ht, second line, it tells you that
!
is e9ual to
1 *2 there is a 1 in the blan$ belo# it. *, you had a one in the ,ourth column ,rom the ri%ht,
:
,
you #ould have a value o, ; turned <(. Any#here that you do not have a 1 in the bottom line,
you #ill ,ill in #ith a 7ero. Thin$ o, each o, these columns bein% able to be turned <( and <22
by usin% a 1 or a !, respectively.
When you are done ,illin% in your 10s and !0s on the bottom line o, the chart, you can add all the
values that you turned <(, in decimal, ,rom le,t to ri%ht &usin% the second line o, the chart).
Thus, i, you had put a 1 in the
:
column &;) and a 1 in the
!
column &1), you #ould add ; = 1
> 1. That 1 is represented by 1!!1.
These numbers are calculated usin% this table8
'
,
'
+
'
*
'
)
'
(
'
'
'
&
'
%
&'- +) (' &+ - ) ' & / .
% % % % & % % & / &%%&
/et0s loo$ at another e3ample... *, you loo$ at the number :, it #as calculated by havin% a 1 in
the
!
place and a in the
1
place &startin% on the ri%ht-hand side o, the table). *, you add the
1 that you %et ,rom the
!
place and the that you %et ,rom the
1
place, you %et :. *n other
#ords, 1 = > :.
/et0s loo$ at another one. The 1!!! in binary represents ; in decimal because you have a 1 in
the
:
place and that %ives you ;. -ou have !0s in all the other places.
*+ addressin% and binary
The three critical pieces o, in,ormation that you, the net#or$ administrator, provide or a ?H'+
server provides to net#or$ devices &computer, server, router, s#itch, etc.) are8
*+ Address
5ubnet mas$
?e,ault @ate#ay
The net#or$ device immediately converts this in,ormation into binary. 5o, let0s pretend that #e
are that net#or$ device and #e are %iven the ,ollo#in% in,ormation8
*+ Address > 1.1.1.1
5ubnet Aas$ > 55.55.55.!
?e,ault @ate#ay > 1.1.1.5B
The computer converts this in,ormation into binary and calculates the (et#or$ *?. Be,ore #e
can calculate the (et#or$ *?, #e ,irst have to convert ,rom decimal to binary.
'onvertin% decimal to binary
/et0s start #ith convertin% the *+ address to binary. To convert 1.1.1.1 to binary, you ta$e the
octets &the numbers bet#een the decimals) one at a time, li$e this8
1 decimal > 1 binary
1 decimal > 1 binary
1 decimal > 1 binary
1 decimal > 1 binary
An *+ address is : bits in binary, so each octet is ; bits in binary. Because o, this, #e need to
pad the other bits as !0s. That means that 1.1.1.1 in decimal e9uals the ,ollo#in% number in
binary8
!!!!!!!1 !!!!!!!1 !!!!!!!1 !!!!!!!1
That #as easyC To convert the subnet mas$ o, 55.55.55.!, ta$e each octet one at a time,
usin% the table8
'
,
'
+
'
*
'
)
'
(
'
'
'
&
'
%
&'- +) (' &+ - ) ' &
Here is #hat * %et8
55 > 11111111
To do this, * loo$ed at the bottom ro# o, numbers that each binary space represents. * started
#ith
D
, #hich e9uals 1;. 5o, ho# many 1;0s are in 55. The ans#er is 1. 5o * #rite8
5" E 1; > 1D
(o#, ho# many "B0s &the ne3t binary space) are in 1D. The ans#er is 1, so * #rite8 1D E "B >
":
And so on, li$e this8
": E : > :1
:1 E 1" > 15
15 E ; > D
D E B > :
: E > 1
1 E 1 > !
5o, * used all ; binary spaces to calculate the 55 in decimal, to be 11111111 in binary. The last
octet is a !, so ! in binary is ! but #e #rite !!!!!!!!. As you %et more e3perience you #ill
already $no# that ei%ht 10s in binary e9uals 55 in decimal.
The total subnet mas$ in binary is8
11111111 11111111 11111111 !!!!!!!!
5o, here is our *+ address and subnet mas$ in binary8
!!!!!!!1 !!!!!!!1 !!!!!!!1 !!!!!!!1
11111111 11111111 11111111 !!!!!!!!
'alculatin% the (et#or$ *?
The net#or$ device on #hich you con,i%ured this *+ addressin% in,ormation must $no# #hat its
net#or$ *? is. The net#or$ *? tells the device #hat its local net#or$ is. *, the destination *+
address ,or the net#or$ device #ith #hich this net#or$ device is tryin% to communicate is not
on its local net#or$, that tra,,ic is sent to the de,ault %ate#ay. Thus, the de,ault %ate#ay is used
only i, the destination ,or the tra,,ic your device is sendin% is not on your local net#or$.
To calculate the (et#or$ *?, start o,, #ith the *+ address and subnet mas$ in binary, ,rom
above8
I 0ddress %%%%%%%& %%%%%%%& %%%%%%%& %%%%%%%&
1ubnet 2ask &&&&&&&& &&&&&&&& &&&&&&&& %%%%%%%%
+er,orm a lo%ical A(? on these. A lo%ical A(? is a math ,unction #here you loo$ at each ro#
and calculate an ans#er based on the ,ollo#in% rules8
! and ! > !
! and 1 > !
1 and 1 > 1
*n our case, this is the ans#er you %et8
I 0ddress %%%%%%%& %%%%%%%& %%%%%%%& %%%%%%%&
1ubnet 2ask &&&&&&&& &&&&&&&& &&&&&&&& %%%%%%%%
03#
3etwork I# %%%%%%%& %%%%%%%& %%%%%%%& %%%%%%%%
4sin% the A(? rules, * loo$ at the ,irst ! in the *+ address and the ,irst 1 in the subnet mas$. *
see that, accordin% to the rules, a ! and a 1 > !. That is ho# * calculated the ,irst ! in the
net#or$ *?. To continue, * %o ,rom le,t to ri%ht, calculatin% each ro#.
(otice that the only di,,erence bet#een the *+ address and net#or$ *? is in the last number o,
the last octet. (o#, to %et the (et#or$ *? in decimal, #e convert this bac$. This is a simple
e3ample, so convertin% it bac$ is easy. The !!!!!!!1 in binary is converted to 1 in decimal. *n
the last octet, the !!!!!!!! is converted to !. This ma$es our net#or$ *?8
1.1.1.!
5o, #hen the net#or$ device #ants to communicate #ith a host that has the *+ address o,
1.1.1.!!, it compares this #ith its net#or$ *? and ,inds that this host is on the local net#or$.
The net#or$ device can then communicate directly #ith it because it is on the 1.1.1.! net#or$.
*, the net#or$ device #ants to communicate #ith host 1.1..1, ho#ever, it ,inds that this is (<T
on its local net#or$ &the 1.1.1.! net#or$) and it sends this tra,,ic to the de,ault %ate#ay.
These e3amples are, o, course, very simpli,ied, since this topic can %et very comple3 #hen you
be%in subnettin% net#or$s and usin% variable-len%th subnet mas$s.
Article 5ummary
Here is #hat #e have learned8
Binary is a numberin% system usin% only 1 and !.
4se the binary conversion chart to convert ,rom binary to decimal and bac$.
-our net#or$ deviceFcomputer calculates the (et#or$ *? usin% the *+ address and
subnet mas$ it is provided.
To calculate the (et#or$ *?, the computer per,orms a math calculation called a Glo%ical
A(?.G
A de,ault %ate#ay is not re9uired ,or a device that #ill not communicate outside its local
net#or$.

Vous aimerez peut-être aussi