ID:               14668
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         Documentation problem
 Operating System: SuSE Linux 7.1
 PHP Version:      4.1.0
 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

You are using ip2long, which in many cases will return a interger value
greater then 2147483647 (on 32 bit machines). Since, PHP normally
treats numbers as signed, numbers greater then 2147483647 become
negative. The solution to your problem would be to use 
sprintf("%u", base_convert(ip2long("255.255.0.255" ) ^ 
0xFFFFFFFF, 10, 2 ));
This will tell php to treat the number as an unsigned integer, allowing
it to go as high as 4294967295, which is largest value ip2long can
possibly return.


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

[2002-05-04 00:13:42] [EMAIL PROTECTED]

Don't use ip2long/long2ip. It just dosen't work. 
Do it by yourself with bcmath.

Manual page should clearly note the limitation.
Changed to doc problem to see if manual is ok.



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

[2001-12-23 06:55:25] [EMAIL PROTECTED]

Hi,

using ip2long is strange enough itself (would you please 
do some better description on what I get out after calling 
this function or at least do some references to documents 
(RFCs) describing that "IP address in full length 
notation" format).

Anyhow: I'm coding the following

<?php
$a = base_convert( 0xFFFFFFFF ^ 1, 10 2 );
var_dump( $a );
?>

and get

string(2) "10"

(under 4.0.6 I got something different: 31 (!!!!) 1's in 
string without that trailing 0)

what about all the other leading bits that should be 1?



And in relation with the ip2long-trouble I'm having:

<?php
$a = base_convert( ip2long( "255.255.0.255" ), 10, 2 );
$b = base_convert( ip2long( "255.255.0.255" ) ^ 
0xFFFFFFFF, 10, 2 );

var_dump( $a, $b );

?>

what gives me

string(16) "1111111100000001" string(16) "1111111100000000"



I beg to get some fast response! This behaviour of ip2long 
and/or xor-operator is too strange to be easily understood 
after reading that minimal function reference entry. But I 
need it a lot for some work that needs to be done 
urgently!!

Thank you very much!


Regards,
Thomas Urban



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


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


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to