# Convert IP to integer and vice versa

**URL:** <https://forum.kirupa.com/t/convert-ip-to-integer-and-vice-versa/303933>\
**Category:** programming\
**Created:** [January 29, 2010, 8:00am UTC](https://forum.kirupa.com/t/convert-ip-to-integer-and-vice-versa/303933 "2010-01-29T08:00:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![srcollection1](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@srcollection1](https://forum.kirupa.com/u/srcollection1)\
**Post date:** [January 29, 2010, 8:00am UTC](https://forum.kirupa.com/t/convert-ip-to-integer-and-vice-versa/303933/1 "2010-01-29T08:00:08Z")

</div>

[COLOR=#000000][FONT=Times New Roman][FONT=verdana]I know how to convert an IP address into an integer… like so:

IP: 10.11.12.13

$a = 10  
$b = 11  
$c = 12  
$d = 13

($a \* 256 to the third) + ($b \* 256 squared) + ($c \* 256) + ($d) = the integer  
or  
($a \* 16777216) + ($b \* 65536) + ($c \* 256) + ($d) = the integer

Now, how do you take the final integer and and convert it back to a regular ip address with decimals and all?
