ID:               39301
 User updated by:  fly2k at bk dot ru
 Reported By:      fly2k at bk dot ru
 Status:           Bogus
 Bug Type:         Network related
 Operating System: N/A
 PHP Version:      5.1.6
 New Comment:

Can't agree... quote from http://php.net/ip2long:

Because PHP's integer type is signed, and many IP addresses will result
in negative integers, you need to use the "%u" formatter of sprintf() or
printf() to get the string representation of the unsigned IP address.
---

So, interger type is signed, results may be signed, and _IF_I_NEED_
unsigned, I will use %u or so... But what if I dont need and signed is
ok for me? I want signed value but on x86_64 I gets unsigned... In any
case, any function must return same result for same parameter at any
platform, is not?


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

[2006-10-30 08:42:19] [EMAIL PROTECTED]

.

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

[2006-10-30 07:57:59] judas dot iscariote at gmail dot com

actually this is the expected behavior. to obtain the correct result,
to what the documentation clearly states.

use the "%u" formatter of sprintf() or printf().

http://php.net/ip2long

and then you will get the correct result both arch

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

[2006-10-30 01:12:11] fly2k at bk dot ru

Description:
------------
$ip='255.255.255.254';
$iplong=ip2long($ip);
print($iplong);

Must print -2 as documented. But on x86_64 returns 4294967294.

Tried on two different hosts - one athlon64 with gentoo, other athlon64
with FC.

Reproduce code:
---------------
$ip='255.255.255.254';
$iplong=ip2long($ip);
print($iplong);

Expected result:
----------------
-2

Actual result:
--------------
4294967294


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


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

Reply via email to