Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2012 11:07
Show Gist options
  • Select an option

  • Save anonymous/3236290 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/3236290 to your computer and use it in GitHub Desktop.
def decimal_ip(ip)
a, b,c, d = ip.split(".")
(((2**24) * a.to_f) + ((2**16) * b.to_f) + ((2**8) * c.to_f) + d.to_f).to_i
end
decimal_ip(ARGV[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment