#18816 [Opn->Csd]: results of ip2long and crc32 differ on different os/architectures

From: Date: Mon, 20 Jan 2003 04:08:49 +0000
Subject: #18816 [Opn->Csd]: results of ip2long and crc32 differ on different os/architectures
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969351093@lists.php.net to get a copy of this message
ID: 18816 Updated by: pollita@php.net Reported By: nohn@php.net -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Linux, Tru64 PHP Version: 4CVS-2002-08-08 New Comment: This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2002-08-10 06:59:59] yohgaki@php.net All functions that requrie unsigned int may be affected. BTW, PostgreSQL OID is free from this restriction, since I changed source to use string if value is larger than 2^31. So postgreSQL document can be left as is. ------------------------------------------------------------------------ [2002-08-08 17:01:31] nohn@php.net Reopened this. This should definitly be documented! On ip2long documentation it is, on crc32 it is not. Which other functions are affected by this? ------------------------------------------------------------------------ [2002-08-08 16:23:55] iliaa@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is because you are using 2 different architectures, on X86 (AMD k6) ints are 32 bit, but on Compaq Tru64 (ALpha EV68) they are 64 bit. Since PHP uses signed ints you got a negative number on X86 where signed ints are limited to 2147483647 and your result is >3 billion. If you explicitly tell PHP to output an unsigned number it will work correctly. printf("%u", ip2long('192.168.0.1')); ----- 3232235521 Same logic applies to your crc, example. ------------------------------------------------------------------------ [2002-08-08 16:09:58] nohn@php.net Ahh... Please note that I may not be reachable in the next days for questions, but you may use http://www.testdrive.compaq.com/ to verify this ------------------------------------------------------------------------ [2002-08-08 16:08:45] nohn@php.net Following Script produces this output: $ip = "192.168.0.1"; echo("$ip\n"); echo(ip2long($ip)); ---- On Debian/i386 (AMD K6): 192.168.0.1 -1062731775 ---- On Compaq Tru64 (ALpha EV68): 192.168.0.1 3232235521 =========================================================================================================== Following Script produces this output: $text = "Der schnelle braune Fuchs springt über den blöden Hund."; echo "$text\n"; echo(crc32($text)); ---- On Debian/i386 (AMD K6): Der schnelle braune Fuchs springt über den blöden Hund. -2050320634 ---- On Compaq Tru64 (Alpha EV68): Der schnelle braune Fuchs springt über den blöden Hund. 1367081892 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18816&edit=1

« previous php.doc (#969351093) next »