# Decimal to binary. Subtract or Add?

Posts: 7Member ■□□□□□□□□□
Hi, when converting binary to decimal I was taught to create a table and add up the 1s. I.e :

128.64.32.16.8.4.2.1
O0001001

Equal 9 (pretty straightforward)

When converting decimal to binary, I was taught to use the same table above but to subtract the IP Address. So.

240.240.240.0
128 64 32 16 8 4 2 1

You would say can 128 be subtracted from 240? If yes place a 1, if not place a 0, and so on as you go through all the octets.

But, could you not just use the table and place ones in the columns from left to right until you get to 240 I.e add them up. Or, am I missing something?

Hope some one can clarify.

• Posts: 2,741Member
Yes do whichever way works for you.

Generally I know that if it's at least 128 then stick a 1 in the 128 column and go from there. I'm pretty quick at subnetting now after years of practice, but that's essentially how I do it.
• Posts: 129Member
Yes it could be done that way as well. You can either subtract 240 - 128 or you can add 128 + 64 + 32 + 16 to get to 240. While you are first learning sub netting subtracting is easier because your end number will be 0 but once you seen examples, now what I do is i usually just add it in my head.

Also
128.64.32.16.8.4.2.1
O0001001

Equal 9 (pretty straightforward)

How did you get 9? As there are only 8 bits there
Each octect only contains 8 bits so from what you are showing up there you only have 8. (9 could be a typing error?)
• Posts: 95Member ■■□□□□□□□□
I watch a video by Scott Morris and Keith Barker related to subnetting, they used what they called the Morris-Barker (Magic Box) key, which really seemed to help me when trying subnet and do it quickly. Here is a link to the video, kinda dry but it helps to explain the method and the madness behind it. I have attached a PDF version of the key that I created. Practice, Practice, Practice.
In Progress:
WGU B.S. - I.T. - Security (and all the certs that come with it)
• Posts: 7Member ■□□□□□□□□□
Thank you. Sorry the first 1 was supposed to be under the 8. The second 1 under the 1 =9

So 9 in Binary

00001001
• Posts: 7Member ■□□□□□□□□□
Thank you. Sorry the first 1 was supposed to be under the 8. The second 1 under the 1.

So 9 in Binary 00001001
• Posts: 7Member ■□□□□□□□□□
Thanks CCIE Wannabe. Will check it out. Everytime I think I have cracked subnetting I keep coming up with more questions. Will persevere.
• Posts: 95Member ■■□□□□□□□□
Phandy wrote: »
Thanks CCIE Wannabe. Will check it out. Everytime I think I have cracked subnetting I keep coming up with more questions. Will persevere.

You're welcome!

By the way you are not alone, subnetting will forever be intertwined with your networking career. The fact that you have questions means you're learning. Keep it up, it does get a little easier to understand the more you get exposure to it.
In Progress:
WGU B.S. - I.T. - Security (and all the certs that come with it)
• Posts: 2,741Member
Oh yeah, I'm 8 years a network engineer now - and subnetting is everywhere.