> From: Sean Cazzell [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, May 20, 2001 8:41 AM
[...]
> It appears that the integer type being used by these functions is not able
> to store the entire 32 bits (4 bytes).  It can only handle up to 31 bits -
> my guess is the type is signed when it should be unsigned.
>
> In any case,I'm running PHP 4.0.5 on Linux 2.4.3 on an x86 machine.  I
> would appreciate it if a someone can verify this before I submit it as a
> bug.
>
[...]
You're right. Integers are allways signed and therefore 31 Bit. Use this:

$ip = '192.168.100.102';
$lo = ip2long($ip);
if ($lo < 0) $lo += pow(2,32);

$lo does now contain the right value, PHP internally converts the data type
to double.
BTW, long2ip() accepts both values, a signed integer or a double value.

I think this isn't a bug, it is due to the pure type concept of PHP,
where no real long-values or bigint (like MySQL) are possible.
Put a better type concept on your wishlist for PHP 5.

Joerg
[EMAIL PROTECTED]
www.php.comzept.de


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to