Decimal to binary. Subtract or Add?

PhandyPhandy Member Posts: 7 ■□□□□□□□□□
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.

Comments

  • gorebrushgorebrush Member Posts: 2,743 ■■■■■■■□□□
    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.
  • tecnodog7tecnodog7 Member Posts: 129
    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)

    head
    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?)
  • CCIE Wanna BeCCIE Wanna Be Member Posts: 95 ■■□□□□□□□□
    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)
  • PhandyPhandy Member Posts: 7 ■□□□□□□□□□
    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
  • PhandyPhandy Member Posts: 7 ■□□□□□□□□□
    Thank you. Sorry the first 1 was supposed to be under the 8. The second 1 under the 1.

    So 9 in Binary 00001001
  • PhandyPhandy Member Posts: 7 ■□□□□□□□□□
    Thanks CCIE Wannabe. Will check it out. Everytime I think I have cracked subnetting I keep coming up with more questions. Will persevere.
  • CCIE Wanna BeCCIE Wanna Be Member Posts: 95 ■■□□□□□□□□
    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)
  • gorebrushgorebrush Member Posts: 2,743 ■■■■■■■□□□
    Oh yeah, I'm 8 years a network engineer now - and subnetting is everywhere.
Sign In or Register to comment.