ID: 27710
User updated by: phpbug at labres dot at
Reported By: phpbug at labres dot at
Status: Open
Bug Type: Math related
-Operating System: Linux (debian woody)
+Operating System: Linux, FreeBSD
PHP Version: 4.3.4
New Comment:
tested on different OS'es.
Previous Comments:
------------------------------------------------------------------------
[2004-03-26 05:11:48] phpbug at labres dot at
Description:
------------
When given network addresses (partial ip addresses)*),
ip2long() calculates erratic values:
Input Output dechex should be
192 int(192) c0 c0000000
192.168 int(-1073741656) c00000a8 c0a80000
192.168.1 int(-1062731775) c0a80001 c0a80100
*) you will need this to convert 192/8, 192.168/16 etc
network addresses.
Reproduce code:
---------------
$net=ip2long("192");
echo dechex($net)."\n";
$net=ip2long("192.168");
echo dechex($net)."\n";
$net=ip2long("192.168.1");
echo dechex($net)."\n";
Expected result:
----------------
c0000000
c0a80000
c0a80100
Actual result:
--------------
c0
c00000a8
c0a80001
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27710&edit=1