<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.bc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.bccomp.php',
    1 => 'bccomp',
    2 => '2 つの任意精度数値を比較する',
  ),
  'up' => 
  array (
    0 => 'ref.bc.php',
    1 => 'BC Math 関数',
  ),
  'prev' => 
  array (
    0 => 'function.bcceil.php',
    1 => 'bcceil',
  ),
  'next' => 
  array (
    0 => 'function.bcdiv.php',
    1 => 'bcdiv',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/bc/functions/bccomp.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.bccomp" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">bccomp</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">bccomp</span> &mdash; <span class="dc-title">2 つの任意精度数値を比較する</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.bccomp-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>bccomp</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$num1</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$num2</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$scale</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   <code class="parameter">num1</code> と
   <code class="parameter">num2</code> を比較し、
   比較結果を整数値で返します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.bccomp-parameters">
  <h3 class="title">パラメータ</h3><p class="para">
   <dl>
    
     <dt><code class="parameter">num1</code></dt>
     <dd>
      <p class="para">
       左オペランドを表す文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">num2</code></dt>
     <dd>
      <p class="para">
       右オペランドを表す文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">scale</code></dt>
     <dd>
      <span class="simpara">
       結果の小数点以下の桁数を指定します。<strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> の場合は、 <span class="function"><a href="function.bcscale.php" class="function">bcscale()</a></span> 関数でグローバルに
       設定した桁数をデフォルトとして使用します。
       それも設定されていない場合は <a href="bc.configuration.php#ini.bcmath.scale" class="link"><code class="literal">bcmath.scale</code></a>
       INI ディレクティブの値を使用します。
      </span>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.bccomp-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   ふたつのオペランドが等しければ <code class="literal">0</code>、
   <code class="parameter">num1</code> が <code class="parameter">num2</code>
   より大きければ戻り値は <code class="literal">1</code>、小さければ <code class="literal">-1</code> を返します。
  </p>
 </div>

 
 <div class="refsect1 errors" id="refsect1-function.bccomp-errors">
  <h3 class="title">エラー / 例外</h3>
  <p class="para">
   この関数は、以下の場合に <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> をスローします:
   <ul class="simplelist">
    <li><code class="parameter">num1</code> もしくは <code class="parameter">num1</code> が、BCMath で有効でない数値形式の文字列である場合</li>
    <li><code class="parameter">scale</code> が範囲外の値である場合</li>
   </ul>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.bccomp-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">scale</code> は、nullable になりました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.bccomp-examples">
  <h3 class="title">例</h3>
  <div class="example" id="example-1">
   <p><strong>例1 <span class="function"><strong>bccomp()</strong></span> の例</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">bccomp</span><span style="color: #007700">(</span><span style="color: #DD0000">'1'</span><span style="color: #007700">, </span><span style="color: #DD0000">'2'</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;   </span><span style="color: #FF8000">// -1<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">bccomp</span><span style="color: #007700">(</span><span style="color: #DD0000">'1.00001'</span><span style="color: #007700">, </span><span style="color: #DD0000">'1'</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">); </span><span style="color: #FF8000">// 0<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">bccomp</span><span style="color: #007700">(</span><span style="color: #DD0000">'1.00001'</span><span style="color: #007700">, </span><span style="color: #DD0000">'1'</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">); </span><span style="color: #FF8000">// 1<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.bccomp-seealso">
  <h3 class="title">参考</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="bcmath-number.compare.php" class="methodname" rel="rdfs-seeAlso">BcMath\Number::compare()</a> - 任意精度数値を比較する</span></li>
  </ul>
 </div>

</div><?php manual_footer($setup); ?>