PHP计算出以下哪一项加起来就是最终的数字

PHP计算出以下哪一项加起来就是最终的数字,php,binary,Php,Binary,我有一组预先确定的值: 1000000000000000000000000000000000000000 100000000000000000000000000000000000000 10000000000000000000000000000000000000 1000000000000000000000000000000000000 100000000000000000000000000000000000 10000000000000000000000000000000000 1000000

我有一组预先确定的值:

1000000000000000000000000000000000000000
100000000000000000000000000000000000000
10000000000000000000000000000000000000
1000000000000000000000000000000000000
100000000000000000000000000000000000
10000000000000000000000000000000000
1000000000000000000000000000000000
100000000000000000000000000000000
10000000000000000000000000000000
1000000000000000000000000000000
100000000000000000000000000000
10000000000000000000000000000
1000000000000000000000000000
100000000000000000000000000
10000000000000000000000000
1000000000000000000000000
100000000000000000000000
10000000000000000000000
1000000000000000000000
100000000000000000000
10000000000000000000
1000000000000000000
100000000000000000
10000000000000000
1000000000000000
100000000000000
10000000000000
1000000000000
100000000000
10000000000
1000000000
100000000
10000000
1000000
100000
10000
1000
100
10
1
我得到了另一个值:

1000000100100000000000000000000000
如何计算出给定的二进制值加起来是什么组合

注意,这些值有时是预定义值中的一个,有时可以是所有预定义值

对我来说这看起来很简单,但我画的是空白

干杯

对于那些希望看到我迄今为止的尝试的人。。给你

.....



  $DBH = new PDO("dblib:host=$myServer;dbname=$SystemDB", $myUser, $myPass);
  $DBH1 = new PDO("dblib:host=$myServer;dbname=$TaxiHistoryDB", $myUser, $myPass);


  $sth = $DBH->prepare("SELECT dbo.Conditions.Name, dbo.Conditions.ConditionValue FROM dbo.Conditions Where dbo.Conditions.ConditionID > 0");
  $sth->execute();

  $result = $sth->fetchAll();
  print_r($result);
  echo "<br>";
  echo "<br>";
  $result = array_reverse($result);
  $STH1 = $DBH1->query("SELECT dbo.tblBooking.Conditions FROM dbo.tblBooking WHERE dbo.tblBooking.BookingID = '36661447'");

  $STH1->setFetchMode(PDO::FETCH_LAZY);

  while($row1 = $STH1->fetch()){
     $condition = $row1->Conditions;
     echo $condition;
     echo "<br>";
     echo base_convert($condition, 10, 2);
     echo "<br>";
     $value = $result['ConditionValue'];
     echo $value;
     foreach($result as $array) {

         $value = $array['ConditionValue']; 
         $binaryCondition = base_convert($condition, 10, 2);
         $binaryValue = base_convert($value, 10, 2);
         echo "<br>";
         echo $binaryValue;

       }//end foreach
    }//end while
。。。。。
$DBH=newpdo(“dblib:host=$myServer;dbname=$SystemDB”,$myUser,$myPass);
$DBH1=新PDO(“dblib:host=$myServer;dbname=$TaxiHistoryDB”,$myUser,$myPass);
$sth=$DBH->prepare(“从dbo.Conditions中选择dbo.Conditions.Name,dbo.Conditions.ConditionValue,其中dbo.Conditions.ConditionID>0”);
$sth->execute();
$result=$sth->fetchAll();
打印(结果);
回声“
”; 回声“
”; $result=array\u reverse($result); $STH1=$DBH1->query(“从dbo.tblBooking中选择dbo.tblBooking.Conditions,其中dbo.tblBooking.BookingID='36661447'”; $STH1->setFetchMode(PDO::FETCH_LAZY); 而($row1=$STH1->fetch()){ $condition=$row1->Conditions; 回声状态; 回声“
”; 回波基_转换($condition,10,2); 回声“
”; $value=$result['ConditionValue']; echo美元价值; foreach($result作为$array){ $value=$array['ConditionValue']; $binaryCondition=base_convert($condition,10,2); $binaryValue=base_convert($value,10,2); 回声“
”; echo$binaryValue; }//端部foreach }//结束时
我将给你一个答案,而不是解释它,因为看起来你根本没有尝试过!如果这是家庭作业,那么你得到它是有原因的

$possible_bits = array(
'1000000000000000000000000000000000000000',
'100000000000000000000000000000000000000',
'10000000000000000000000000000000000000',
'1000000000000000000000000000000000000',
'100000000000000000000000000000000000',
'10000000000000000000000000000000000',
'1000000000000000000000000000000000',
'100000000000000000000000000000000',
'10000000000000000000000000000000',
'1000000000000000000000000000000',
'100000000000000000000000000000',
'10000000000000000000000000000',
'1000000000000000000000000000',
'100000000000000000000000000',
'10000000000000000000000000',
'1000000000000000000000000',
'100000000000000000000000',
'10000000000000000000000',
'1000000000000000000000',
'100000000000000000000',
'10000000000000000000',
'1000000000000000000',
'100000000000000000',
'10000000000000000',
'1000000000000000',
'100000000000000',
'10000000000000',
'1000000000000',
'100000000000',
'10000000000',
'1000000000',
'100000000',
'10000000',
'1000000',
'100000',
'10000',
'1000',
'100',
'10',
'1');

$test_number = '1000000100100000000000000000000000';
$test_number_lsb = bindec(substr($test_number, -32));
$test_number_msb = bindec(substr_replace($test_number, '', -33));

foreach(array_reverse($possible_bits) as $bit => $bit_value){
    $dec_value_lsb = bindec(substr($bit_value, -32));
    $dec_value_msb = bindec(substr_replace($bit_value, '', -33));    
    if($test_number_lsb & $dec_value_lsb || $test_number_msb & $dec_value_msb)
        echo $bit."\n";
}
我已将其更新为32位,请看


这是你的家庭作业吗?如果你希望有人帮助你,你需要展示你所做的努力。。但我在32位处理方面一直存在问题@代达洛桑我们看到的代码是
Go
Go
,在我的答案的注释中位于底部。我认为这包括查看数字和1的位置。我基本上已经这样做了。我知道答案是:10000000000000000000000000000000000000000000000000000000000000000000000000000000000000,10000000000000000000000000,我明白你的答案是什么。。但是它没有给我结果。我认为这是一个32位与64位的问题。用你所拥有的更新你的问题-你首先应该这样做。在我的回答中应该非常清楚如何获得你所需要的信息。你现在找错了方向。你的代码给我的结果是“23 26”。我不明白这怎么可能是正确的???因为它是在呼应匹配位的位位置。如果这不是你想要的,在这个循环中还有其他的东西你可以回应。
<?php

$test = bindec(1000000100100000000000000000000000);

for ($i = 0; $i < 40; $i++)
    if (bindec($bit = pow(10, $i)) & $test)
        echo $bit . "\n";