#36967 [Opn->Bgs]: ip2long returns unsigned long instead of signed long

From: Date: Tue, 04 Apr 2006 16:36:22 +0000
Subject: #36967 [Opn->Bgs]: ip2long returns unsigned long instead of signed long
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95305@lists.php.net to get a copy of this message
 ID:               36967
 Updated by:       derick@php.net
 Reported By:      php at cakkie dot be
-Status:           Open
+Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: Linux Gentoo
 PHP Version:      4.4.2
 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

It's actually correct as your 2nd machine is a 64bit machine, where
PHP's integers are also 64bit. To make this portable, use sprintf("%u",
ip2long(....));


Previous Comments:
------------------------------------------------------------------------

[2006-04-04 15:39:09] php at cakkie dot be

Description:
------------
I'm using the same code on 2 servers.

One server is a 2.6.6 debian with PHP 4.3.10
This one returns a signed long (as it should according to the
documentation)

The other server is a 2.6.14 Gentoo with PHP 4.4.0
This one returns an unsigned long (not what it should be)

Since I didn't find any bugreport, nor other information regarding this
behaviour, I decided to post a bug.

As a reference, I have an example, along with phpinfo() running at both
servers:
correct: http://www.funpages.be/index.php
incorrect: http://www.factsoflife.be/cakkie/index.php


Reproduce code:
---------------
echo ip2long('217.136.232.103');

Expected result:
----------------
-645339033


Actual result:
--------------
3649628263


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36967&edit=1


Thread (2 messages)

« previous php.bugs (#95305) next »