-2

私は事前に決定された値のセットを持っています:

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

バイナリ値のどの組み合わせが与えられたものになるかをどのように計算するのですか?

値は事前定義された値の 1 つだけである場合もあれば、すべての値である場合もあることに注意してください。

私には単純に見えますが、空白を描いています!

乾杯!

これまでの私の試みを見たい人のために..ここに行く

.....



  $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
4

2 に答える 2

2

あなたが試したこともないように見えるので、説明はせずに答えを出します!これが宿題なら、あなたはそれを与えられたのには理由があります。

$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ビットにチャンクするように更新しました

于 2013-09-19T03:53:31.027 に答える