PHP returns a negative number?

Posted by Legend on Stack Overflow See other posts from Stack Overflow or by Legend
Published on 2010-04-16T04:04:27Z Indexed on 2010/04/16 4:13 UTC
Read the original article Hit count: 200

Filed under:
|
|

I am trying to query a bittorrent tracker and am using unpack to get the list of IPs from the response. So, something like this:

$ip = unpack("N", $peers);
$ip_add = ($ip[1]>>24) . "." . (($ip[1]&0x00FF0000)>>16) . "." . (($ip[1]&0x0000FF00)>>8) . "." . ($ip[1]&0x000000FF);

But, for some reason, I am getting the following IP addresses when I print $ip_add:

117.254.136.66
121.219.20.250
-43.7.52.163

Does anyone know what could be going wrong?

© Stack Overflow or respective owner

Related posts about php

Related posts about php5