Converting decimal numbers into binary

nusyo

Member
Feb 27, 2011
106
0
0
More precisely I am referring to converting an ip address into binary. Do people look at an IP address and are able to convert it right away into binary and the other way around?

I mean , i know how it's done, but is it required to know this without pencil and paper?

I started to take some network classes and kinda work my way to either a degree or certifications.

Thanks
 

ScottMac

Moderator<br>Networking<br>Elite member
Mar 19, 2001
5,471
2
0
It's not that hard once you get the hang of it.
You get uses to the numerical progression.
 

her209

No Lifer
Oct 11, 2000
56,336
11
0
Given a decimal number and start with the LSB going to the MSB:
Step 1. If its even, write 0. If its odd, write 1.
Step 2. If its even, divide by 2. If its odd, subtract 1 then divide by 2.
Step 3. With the new number, repeat step 1 until you reach 0.
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
More precisely I am referring to converting an ip address into binary. Do people look at an IP address and are able to convert it right away into binary and the other way around?

I mean , i know how it's done, but is it required to know this without pencil and paper?

us your fingers (but not thumbs) to keep up with the 8 bits (and their equivalent values) for each octet, makes dealing with subnet masks/host ranges not too bad with some practice

youll probably want something to scribble on if you have to convert an entire address, that would otherwise need several fingers.

also:

http://www.subnettingquestions.com/

it helps to practice regularly.
 

nusyo

Member
Feb 27, 2011
106
0
0
Thank you.
When you go deep into something, it seems so complicated.

There is no other way to subnet a network but to use the formula y=2^n-2 which involves binary digits, right?

I am slowly making progress :)
 

bobdole369

Diamond Member
Dec 15, 2004
4,504
2
0
I do it in my head. That being said I also know my immediate gas mileage and pi out to about 40 places, AND always have a binary clock running somewhere. You don't need to do this in the real world.
 

drebo

Diamond Member
Feb 24, 2006
7,034
1
81
The only thing related to IP addressing you need to be able to understand in binary terms are subnet and wildcard masks. Otherwise, there's very little reason to convert an IP address to binary.

Once you understand subnetting, you'll realize that it's a lot easier than that ridiculous formula makes it seem.

For instance, if you're given 192.168.0.0/16 and you're told that you need 100 subnets, all you need to do is figure out which power of 2 gives you the number over 100. 2^7 = 128, meaning you need 7 bits to identify subnets. That means that each subnet is going to have a /23 (16+7) subnet mask (255.255.254.0).

If, on the other hand, you are given 192.168.0.0/16 and are told that you need multiple subnets with 480 hosts in them, you work backwards. 2^9 = 512, so each subnet needs 9 host bits. That means each subnet has to have a /23 (32-9) subnet mask (again, 255.255.254.0).

Learn your powers of 2 and understand what a subnet mask actually does, and subnetting is incredibly easy. No binary necessary, other than to recognize that /23 means 23 consecutive 1's followed by 9 consecutive 0's to form the subnet mask, represented in decimal as 255.255.254.0. But, there are really only 8 numbers you need to remember:

00000000 = 0
10000000 = 128
11000000 = 192
11100000 = 224
11110000 = 240
11111000 = 248
11111100 = 252
11111110 = 254
11111111 = 255

Once those become second nature, nothing else matters.
 

drebo

Diamond Member
Feb 24, 2006
7,034
1
81
Let me amend that by saying that the freak who designed EUI-64 addressing for IPv6 is a sadistic fucker and makes you figure out the first 8 binary digits of the MAC address so you can arbitrarily flip the 7th bit and then convert back to hex. It performs no functional purpose and adds nothing to the IPv6 standard, but you have to do it anyway.
 

airdata

Diamond Member
Jul 11, 2010
4,987
0
0
0.0.0.0.0.0.0.0
0. 0. 0. 0. 0.0.0.0
128.64.32.16 8.4.2.1


10000000 = 128
11000000 = 192
11100000 = 224
11110000 = 240
11111000 = 248
11111100 = 252
11111110 = 254
11111111 = 255


00000000 = 0
00000001 = 1
00000010 = 2
00000011 = 3
00000100 = 4
00000101 = 5
00000110 = 6
00000111 = 7
00001111 = 15

Once those become second nature, nothing else matters.

Added a little to your great post.
 
Last edited:

nusyo

Member
Feb 27, 2011
106
0
0
wow the way you guys put it.... it's a lot easier than what's in the books

i am glad i joined the forums :p and btw ... these forums should have a "thank" or "rep points" feature ....
 

airdata

Diamond Member
Jul 11, 2010
4,987
0
0
It's good to look at multiple sources for subjects like binary math and subnetting. For me to get a good grasp, I had to have it explained multiple times and then after the fact do alot of practicing.
 

Lorne

Senior member
Feb 5, 2001
873
1
76
Used to know this crap off the top of my head like it was just another language from programming so much Comodore Basic, 6502 and direct ML.
When the Matrix came out and Cypher was explaining to Neo about looking at the construct lang I remembered those day past.

Now I can hardly remember squat about it