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

From: Date: Thu, 08 Aug 2002 20:23:56 +0000
Subject: #18816 [Opn->Bgs]: results of ip2long and crc32 differ on different os/architectures
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16322@lists.php.net to get a copy of this message
ID: 18816 Updated by: iliaa@php.net -Reported By: nohn@php.net +Reported By: ilia@prohost.org -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Linux, Tru64 PHP Version: 4CVS-2002-08-08 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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.bugs (#16322) next »