IP addresses are 32-bits, unsigned. If you have, for example, 255.0.0.0 as your IP address, in binary notation it looks like this:
11111111000000000000000000000000
The problem is that PHP uses 32-bit, unsigned integers. The leftmost bit in an unsigned int, if == 1, indicates a number is negative. That's fine unless you're trying to manipulate IPs using PHPs... the larger numbers wrap around and become negative.
It might help to do sprintf("%u",ip2long($whatever)). That will print the positive number you want.
Hope that helps,
Jason Signalness
Systems Administrator, BTINet.