Skip to content

Instantly share code, notes, and snippets.

@puterjam
Created April 3, 2015 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puterjam/cded826b5b0f8b9b87d2 to your computer and use it in GitHub Desktop.
Save puterjam/cded826b5b0f8b9b87d2 to your computer and use it in GitHub Desktop.
ip2long long2ip
var ip2long = function(ip){ip = ip.split(".");return (((ip[0] << 24) | (ip[1] << 16) | (ip[2] << 8) | ip[3]) >>> 0)}
var long2ip = function(ip){return [(ip >> 24) & 0xff,(ip >> 16) & 0xff,(ip >> 8) & 0xff,ip & 0xff].join(".")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment