| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2005-01-16 12:59 UTC] php at milonic dot com
 Description:
------------
Values returned using the following code produce different results (incorrect) in PHP-4.3.10 and PHP-4.3.9 on Fedora Core 3. 
When the same code is executed on a Linux 9 or FreeBSD5.3 machine the values are correct.
Could be a Fedora problem but thought you'd like to take a look.
Reproduce code:
---------------
<?
function fillZeros($a, $b){
	$z = hexdec(80000000);
	if ($z & $a){
		$a = ($a>>1);
		$a &= (~$z);
		$a |= 0x40000000;
		$a = ($a>>($b-1));
	}
	else{
		$a = ($a>>$b);
	}
	return $a;
}
function mixture($a,$b,$c) 
{
	$a -= $b; $a -= $c; $a ^= (fillZeros($c,13));
	$b -= $c; $b -= $a; $b ^= ($a<<8);
	$c -= $a; $c -= $b; $c ^= (fillZeros($b,13));
	$a -= $b; $a -= $c; $a ^= (fillZeros($c,12));
	$b -= $c; $b -= $a; $b ^= ($a<<16);
	$c -= $a; $c -= $b; $c ^= (fillZeros($b,5));
	$a -= $b; $a -= $c; $a ^= (fillZeros($c,3)); 
	$b -= $c; $b -= $a; $b ^= ($a<<10);
	$c -= $a; $c -= $b; $c ^= (fillZeros($b,15));
	return array($a,$b,$c);
}
$test= mixture("11", "22", "33");
echo "$test[0], $test[1], $test[2]\n";
?>
Expected result:
----------------
Should be: 
251066875, -1654377486, -1500734959
Actual result:
--------------
But instead get:
251066875, 1541925888, -402039036
Only happens on Fedora, all other boxes are fine.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 06:00:01 2025 UTC | 
Narrowed the problem down to this: $b=251066875; $a=-3111919630; echo $b ^= ($a<<10); Fedora 3 echos: 251066875 (wrong) All other OS's echo: 25768443 (correct) Maybe it helps? Cheers Andy