Alexey Zakhlestin's Blog

Programming for Mac and Web

Ip2long, 32-bit/64-bit


It is a common practice, to use ip2long() function for getting integer-representation of ip-address (for database-storage).


on systems with 32-bit integers, ip2long() returns values from -2147483648 to 2147483647

on systems with 64-bit integers, ip2long() returns values from 0 to 42949672945

Which means, that if you were using INT as a storage type on 32-bit server, you will need to change that field to be UNSIGNED INT (or BIGINT) on 64-bit server.

There is no simple migration, sorry.

p.s. similiar problems can appear in other intger-related functions too