Last active
January 2, 2020 06:37
-
-
Save rg443a/905654d929533a87d6a5c10a61be2fb2 to your computer and use it in GitHub Desktop.
inet_aton, inet_ntoa, ip2int, int2ip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inet_aton(a) { | |
return a.split(".").reduce(function(a, b) { | |
return (a << 8) + parseInt(b, 10); | |
}, 0) >>> 0; | |
} | |
function inet_ntoa(a) { | |
return (a >>> 24) + "." + (a >> 16 & 255) + "." + (a >> 8 & 255) + "." + (a & 255); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment