<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.bcmath-number.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'bcmath-number.round.php',
    1 => 'BcMath\\Number::round',
    2 => 'Arrondit un nombre de pr&eacute;cision arbitraire',
  ),
  'up' => 
  array (
    0 => 'class.bcmath-number.php',
    1 => 'BcMath\\Number',
  ),
  'prev' => 
  array (
    0 => 'bcmath-number.powmod.php',
    1 => 'BcMath\\Number::powmod',
  ),
  'next' => 
  array (
    0 => 'bcmath-number.serialize.php',
    1 => 'BcMath\\Number::__serialize',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/bc/bcmath/number/round.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="bcmath-number.round" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">BcMath\Number::round</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.4.0)</p><p class="refpurpose"><span class="refname">BcMath\Number::round</span> &mdash; <span class="dc-title">Arrondit un nombre de précision arbitraire</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-bcmath-number.round-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>BcMath\Number::round</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$precision</code><span class="initializer"> = 0</span></span>, <span class="methodparam"><span class="type"><a href="enum.roundingmode.php" class="type RoundingMode">RoundingMode</a></span> <code class="parameter">$mode</code><span class="initializer"> = <strong><code>RoundingMode::HalfAwayFromZero</code></strong></span></span>): <span class="type"><a href="class.bcmath-number.php" class="type BcMath\Number">BcMath\Number</a></span></div>

  <p class="simpara">
   Renvoie la valeur arrondie de <var class="varname">$this</var>
   à la <code class="parameter">précision</code> spécifiée
   (le nombre de chiffres après la virgule).
   <code class="parameter">precision</code> peut également être négatif ou nul (par défaut).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-bcmath-number.round-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
   
     <dt><code class="parameter">precision</code></dt>
     <dd>
      <p class="para">
       Le nombre optionnel de décimales à arrondir.
      </p>
      <p class="para">
       Si le paramètre <code class="parameter">precision</code> est positif,
       <code class="parameter">num</code> sera arrondi en utilisant le paramètre
       <code class="parameter">precision</code> pour définir le nombre significatif
       de chiffres après le point décimal.
      </p>
      <p class="para">
       Si le paramètre <code class="parameter">precision</code> est négatif,
       <code class="parameter">num</code> sera arrondi en utilisant le paramètre
       <code class="parameter">precision</code> pour définir le nombre significatif
       de chiffres avant le point décimal, c.-à-d. le multiple le plus proche
       de <code class="code">pow(10, -$precision)</code>, c.-à-d. pour une
       <code class="parameter">precision</code> de -1, <code class="parameter">num</code>
       sera arrondi à 10, pour une <code class="parameter">precision</code> de -2 à 100, etc.
      </p>
     </dd>
    
   
    <dt><code class="parameter">mode</code></dt>
    <dd>
     <span class="simpara">
      Spécifie la méthode d&#039;arrondi. Pour plus d&#039;informations sur les méthodes, voir <span class="enumname"><a href="enum.roundingmode.php" class="enumname">RoundingMode</a></span>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-bcmath-number.round-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Renvoie le résultat sous forme d&#039;un nouvel objet <span class="classname"><a href="class.bcmath-number.php" class="classname">BcMath\Number</a></span>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-bcmath-number.round-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="simpara">
   Cette méthode lève une <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> si un <code class="parameter">mode</code> invalide est spécifié.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-bcmath-number.round-examples">
  <h3 class="title">Exemples</h3>
   <div class="example" id="example-1">
   <p><strong>Exemple #1 Exemple de <span class="methodname"><strong>BcMath\Number::round()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'3.4'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'3.5'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'3.6'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'3.6'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'5.045'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'5.055'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'345'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(-</span><span style="color: #0000BB">2</span><span style="color: #007700">),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'345'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(-</span><span style="color: #0000BB">3</span><span style="color: #007700">),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'678'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(-</span><span style="color: #0000BB">2</span><span style="color: #007700">),<br />    new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'678'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(-</span><span style="color: #0000BB">3</span><span style="color: #007700">),<br />);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">object(BcMath\Number)#2 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;3&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#3 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;4&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;4&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#5 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;4&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#6 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;5.05&quot;
  [&quot;scale&quot;]=&gt;
  int(2)
}
object(BcMath\Number)#7 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;5.06&quot;
  [&quot;scale&quot;]=&gt;
  int(2)
}
object(BcMath\Number)#8 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;300&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#9 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#10 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;700&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#11 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;1000&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}</pre>
</div>
   </div>
  </div>
  <div class="example" id="example-2">
   <p><strong>Exemple #2 
    Exemple d&#039;utilisation de <span class="methodname"><strong>BcMath\Number::round()</strong></span> avec différentes valeurs de <code class="parameter">précision</code>
   </strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$number </span><span style="color: #007700">= new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'123.45'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(-</span><span style="color: #0000BB">1</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(-</span><span style="color: #0000BB">2</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(-</span><span style="color: #0000BB">3</span><span style="color: #007700">),<br />);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">object(BcMath\Number)#2 (2) {
  [&quot;value&quot;]=&gt;
  string(7) &quot;123.450&quot;
  [&quot;scale&quot;]=&gt;
  int(3)
}
object(BcMath\Number)#3 (2) {
  [&quot;value&quot;]=&gt;
  string(6) &quot;123.45&quot;
  [&quot;scale&quot;]=&gt;
  int(2)
}
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(5) &quot;123.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#5 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;123&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#6 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;120&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#7 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;100&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#8 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;0&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}</pre>
</div>
   </div>
  </div>
  <div class="example" id="example-3">
   <p><strong>Exemple #3 
    Exemple d&#039;utilisation de <span class="methodname"><strong>BcMath\Number::round()</strong></span> avec différentes valeurs de <code class="parameter">mode</code>
   </strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Rounding modes with 9.5' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$number </span><span style="color: #007700">= new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'9.5'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfAwayFromZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfTowardsZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfEven</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfOdd</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">TowardsZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">AwayFromZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">NegativeInfinity</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">PositiveInfinity</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Rounding modes with 8.5' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$number </span><span style="color: #007700">= new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'8.5'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfAwayFromZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfTowardsZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfEven</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfOdd</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">TowardsZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">AwayFromZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">NegativeInfinity</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$number</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">PositiveInfinity</span><span style="color: #007700">),<br />);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Rounding modes with 9.5
object(BcMath\Number)#3 (2) {
  [&quot;value&quot;]=&gt;
  string(2) &quot;10&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#5 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#7 (2) {
  [&quot;value&quot;]=&gt;
  string(2) &quot;10&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#9 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#11 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#13 (2) {
  [&quot;value&quot;]=&gt;
  string(2) &quot;10&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#15 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#17 (2) {
  [&quot;value&quot;]=&gt;
  string(2) &quot;10&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}

Rounding modes with 8.5
object(BcMath\Number)#1 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#15 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;8&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#13 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;8&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#11 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#9 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;8&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#7 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#5 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;8&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}
object(BcMath\Number)#3 (2) {
  [&quot;value&quot;]=&gt;
  string(1) &quot;9&quot;
  [&quot;scale&quot;]=&gt;
  int(0)
}</pre>
</div>
   </div>
  </div>
  <div class="example" id="example-4">
   <p><strong>Exemple #4 
    Exemple d&#039;utilisation de <span class="methodname"><strong>BcMath\Number::round()</strong></span> avec différentes valeurs de <code class="parameter">mode</code>
    en spécifiant <code class="parameter">précision</code>
   </strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$positive </span><span style="color: #007700">= new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'1.55'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$negative </span><span style="color: #007700">= new </span><span style="color: #0000BB">BcMath\Number</span><span style="color: #007700">(</span><span style="color: #DD0000">'-1.55'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">'Using RoundingMode::HalfAwayFromZero with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfAwayFromZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfAwayFromZero</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Using RoundingMode::HalfTowardsZero with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfTowardsZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfTowardsZero</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Using RoundingMode::HalfEven with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfEven</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfEven</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Using RoundingMode::HalfOdd with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfOdd</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">HalfOdd</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Using RoundingMode::TowardsZero with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">TowardsZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">TowardsZero</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Using RoundingMode::AwayFromZero with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">AwayFromZero</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">AwayFromZero</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Using RoundingMode::NegativeInfinity with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">NegativeInfinity</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">NegativeInfinity</span><span style="color: #007700">),<br />);<br /><br />echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Using RoundingMode::PositiveInfinity with 1 decimal digit precision' </span><span style="color: #007700">. </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$positive</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">PositiveInfinity</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">$negative</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">round</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">RoundingMode</span><span style="color: #007700">::</span><span style="color: #0000BB">PositiveInfinity</span><span style="color: #007700">),<br />);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Using RoundingMode::HalfAwayFromZero with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#5 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}

Using RoundingMode::HalfTowardsZero with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#6 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}

Using RoundingMode::HalfEven with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#7 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}

Using RoundingMode::HalfOdd with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#8 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}

Using RoundingMode::TowardsZero with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#9 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}

Using RoundingMode::AwayFromZero with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#10 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}

Using RoundingMode::NegativeInfinity with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#11 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}

Using RoundingMode::PositiveInfinity with 1 decimal digit precision
object(BcMath\Number)#4 (2) {
  [&quot;value&quot;]=&gt;
  string(3) &quot;1.6&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}
object(BcMath\Number)#12 (2) {
  [&quot;value&quot;]=&gt;
  string(4) &quot;-1.5&quot;
  [&quot;scale&quot;]=&gt;
  int(1)
}</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-bcmath-number.round-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.bcround.php" class="function" rel="rdfs-seeAlso">bcround()</a> - Arrondit un nombre de pr&eacute;cision arbitraire</span></li>
   <li><span class="methodname"><a href="bcmath-number.ceil.php" class="methodname" rel="rdfs-seeAlso">BcMath\Number::ceil()</a> - Arrondit au sup&eacute;rieur un nombre de pr&eacute;cision arbitraire</span></li>
   <li><span class="methodname"><a href="bcmath-number.floor.php" class="methodname" rel="rdfs-seeAlso">BcMath\Number::floor()</a> - Arrondit &agrave; l'inf&eacute;rieur un nombre de pr&eacute;cision arbitraire</span></li>
  </ul>
 </div>


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