Bug #17202 Updated: long2ip problems with unsigned double

From: Date: Mon, 01 Jul 2002 19:36:38 +0000
Subject: Bug #17202 Updated: long2ip problems with unsigned double
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12700@lists.php.net to get a copy of this message
ID: 17202 Updated by: sander@php.net Reported By: pl@dlh.net -Status: Open +Status: Bogus Bug Type: Network related Operating System: Debian 3.0 / Kernel 2.4.18 PHP Version: 4.2.0 New Comment: PHP has no unsigned numbers, so $ip+=pow(2,32); will mess up (goes beyond the limits of PHP's INT). Not a bug. Previous Comments: ------------------------------------------------------------------------ [2002-05-14 07:13:05] pl@dlh.net When storing ips as unsigned doubles I noticed a strange behaviour when passing unsigned doubles through the long2ip routine. -- sample -- <?php $ip = ip2long("192.168.0.1"); print long2ip($ip)."\n"; if ($ip < 0) $ip+=pow(2,32); //convert from signed to unsigned print long2ip($ip)."\n"; ?> -- end --- In the first line - as supposed - the script returns "192.168.0.1", but after conversion I get an offset by one and it returns "192.168.0.0". I read in the doc that long2ip is capable of handling both signed and unsigned long integers. Peter ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17202&edit=1

« previous php.bugs (#12700) next »