INT2IP
Syntax
INT2IP(int_value)
Description
Converts the integer int_value to an IP address.
Assume that the input value is s. The IP address s4.s3.s2.s1 is calculated as follows:
-
s1=smod 2^8^ -
s2= (s-s1) / 2^8^ mod 2^8^ -
s3= ((s-s1) / 2^8^ -s2) / 2^8^ mod 2^8^ -
s4= (((s-s1) / 2^8^ -s2) / 2^8^ -s3) / 2^8^ mod 2^8^
If the input value is greater than 4294967295 or is NULL, NULL is returned.
Examples
SELECT
INT2IP(16777216),
HEX(16777216),
INT2IP(1)
\G
*************************** 1. row ***************************
INT2IP(16777216): 1.0.0.0
HEX(16777216): 1000000
INT2IP(1): 0.0.0.1
1 row in set (0.001 sec)