Jump to content

Bonus Question :P


tibberous

Recommended Posts

I got it!

 

I took the number an used base_convert($num, 10, 16) to get a series of 8 alpha-numeric characters. Then, I used windows calculator to convert them from base-16 to base-10 2 at a time to get base 256.

 

But, for some reason, the sets are backwords. I only found this out b/c I was playing with my ip address. So, basically, if you get:

 

75.149.00.109

 

You just make it:

 

109.00.149.75

 

So, I kind of solved it, but there is a lot more standard way that just involves modding and dividing. Does anyone know that way?

 

@Teddy:

 

It converts an ip address to a base-10 number, so converting back would be getting the original ip.

Link to comment
Share on other sites

No. They just do the same thing. There's exactly one way to convert IP in form of four octets into a 32bit integer.

BTW: Make sure you use UNSIGNED INTEGER in MySQL for storing IPs.

 

[edit]

 

OC the second one is INET_ATON()

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.