Re: Problems using bitwise &



Philluminati wrote:

$ip = $networkObjectRow['sipv4addr'];
$subnet = $networkObjectRow['eipv4addr'];

//make php treats these likes numbers and not strings

$ip += (int)0;
$subnet += (int)0;

$ip = (int)$networkObjectRow['sipv4addr'];
$subnet = (int)$networkObjectRow['eipv4addr'];



print("<!-- sip F (ip=$ip,subnet=$subnet) returned is
$ans -->\n");
return ($ans);

However my output is like this:

<!-- sip F (ip=170419457,subnet=4294967040) returned is 170419456 -->
<!-- sip F (ip=170419457,subnet=4294967040) returned is 170419456 -->
<!-- sip F (ip=3388826225,subnet=4294967280) returned is -906141072 --
<!-- sip F (ip=3388826225,subnet=4294967280) returned is -906141072 --
<!-- sip F (ip=170419969,subnet=4294967040) returned is 170419968 -->

<!-- sip F (ip=170419969,subnet=4294967040) returned is 170419968 -->

Where the IP starts 17... the answer is correct. When the value starts
3388 the value is wrong.
PHP _outputs_ it as signed integer. Try formatted output to clear this question:

printf("<!-- sip F (ip=%08X,subnet=%08X) returned is %08X -->\n",$ip,$subnet,$ans);
.



Relevant Pages

  • Re: attempting to return values from array from w/in a function
    ... What I get is an array w/ only the most recent array entry. ... I am new to PHP & do not have formal scripting ... you end up comparing strings, but the test you mean probably is simply: ... case 1: {codeblock} ...
    (comp.lang.php)
  • Re: [PHP] pack it in
    ... that's where my brain goes to mush - all strings in php ... in php and such found in these 'binary files' that they need to be ... packallows you to format binary data. ... # Do the conversion the way that the system architecture wants to ...
    (php.general)
  • Re: Storing condition in bitfield?
    ... which I would like to bind form field's validation scheme/condition. ... I believe that in PHP, you can actually store PHP code in strings, and ... opposed to, say, an XML or ASCII representation. ... Putting strings and XML will be of overhead, ...
    (comp.programming)
  • Re: preg_replace
    ... replacement in the two strings you have given. ... input element and every textarea element? ... contain php? ...
    (comp.lang.php)
  • Re: function-arguments by reference
    ... i want to avoid performance-problems by repeated ... function-calls with very long strings. ... (I am not familiar with php, ...
    (comp.lang.python)