ID: 6260
Updated by: derick
Reported By: [EMAIL PROTECTED]
Old-Status: Suspended
Status: Closed
Bug Type: Scripting Engine problem
Operating system: 
PHP Version: 4.0.1pl2
Assigned To: 
Comments:

This is not a bug in PHP, so closing.

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

[2000-08-20 09:50:47] [EMAIL PROTECTED]
PHP integers are signed longs. If you want to go outside signed long, you should use 
bcmath library.

I do not close it since PHP has showed some very strange behaviour on large numbers, 
which might be useful to investigate and decide what to do.

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

[2000-08-20 09:44:58] [EMAIL PROTECTED]
I Compiled php with MySQL and apxs.

php.ini shouldn't be relevant. It was not included in the install (btw. why?) and I've 
only created one with only session related stuff.

I found this thing on a newsgroup, alt.php, a new group not yet found on many servers, 
but you *can* find it on news.cis.dfn.de. The thread is named "a little maths 
problem", started 08/15/00 11:07.

I've considered it for some time now, and I can't find any explanation:
the code snippet
<?php
$val = 2634023077 ^ 407240870;
echo $val;
?>
outputs "-1740242778".

This can't to my knowledge be correct. I mean, 2634023077 would normally be an 
unsigned integer, but I haven't found any way to specify signed/unsigned integers. In 
addition, the answer should be 2235957251, and -1740242778 is not the signed 
representation of that number.

  1001 1101 0000 0000 0000 0000 1010 0101  -  2634023077
^ 0001 1000 0100 0110 0000 0000 1010 0110  -  0407240870
= 1000 0101 0100 0110 0000 0000 0000 0011  -  2235957251

The result from an xor operation performed on these two integers in php is
-1740242778. 1740242778 (positive) is in binary:
0110 0111 1011 1001 1111 1111 0101 1010

Then the negative representation should be (negating each bit and "adding" one):
1001 1000 0100 0110 0000 0000 1010 0110

which unsigned is 2554724518, not 2235957251.

All this taken into consideration, is this a bug/flaw or am I wrong?


--Fredrik de Vibe

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



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=6260&edit=2


-- 
PHP Development 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