<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.math.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'book.bc.php',
    1 => 'BC Math',
    2 => 'Fonctions BCMath',
  ),
  'up' => 
  array (
    0 => 'refs.math.php',
    1 => 'Extensions sur les math&eacute;matiques',
  ),
  'prev' => 
  array (
    0 => 'refs.math.php',
    1 => 'Extensions sur les math&eacute;matiques',
  ),
  'next' => 
  array (
    0 => 'bc.setup.php',
    1 => 'Installation/Configuration',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/bc/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.bc.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.bc" class="book">
 
 <h1 class="title">Fonctions BCMath</h1>
 

 
 <div id="intro.bc" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="para">
   Pour les calculs mathématiques d&#039;une grande précision, PHP fournit
   BCMath, qui supporte n&#039;importe quelle précision et
   n&#039;importe quelle taille de nombres jusqu&#039;à <code class="literal">2147483647</code> (ou
   <code class="literal">0x7FFFFFFF</code>) chiffres décimaux, s&#039;il y a suffisamment de mémoire,
   représentés sous la forme d&#039;une <a href="language.types.string.php" class="link">chaîne de caractères</a>.
  </p>
  <p class="para">
   Les nombres BCMath valides (c.-à-d. bien formés) sont des chaînes qui
   correspondent à l&#039;expression régulière
   <code class="literal">/^[+-]?[0-9]*(\.[0-9]*)?$/</code>.
  </p>
  <div class="caution"><strong class="caution">Attention</strong>
   <p class="para">    
    Le passage de valeurs de type <a href="language.types.float.php" class="link">nombre décimal</a> à une fonction BCMath qui 
    attend une <a href="language.types.string.php" class="link">chaîne de caractères</a> comme opérande peut ne pas avoir l&#039;effet 
    désiré en raison de la façon dont PHP convertit les valeurs 
    <a href="language.types.float.php" class="link">nombre décimal</a> en <a href="language.types.string.php" class="link">chaîne de caractères</a>, à savoir que la 
    <a href="language.types.string.php" class="link">chaîne de caractères</a> peut être en notation exponentielle (ce qui n&#039;est pas 
    supporté par BCMath), et que, antérieurement à PHP 8.0.0,
    le séparateur décimal dépend de la locale
    (tandis que BCMath attend toujours un point décimal).
   </p>
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$num1 </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #FF8000">// (string) 0 =&gt; '0'<br /></span><span style="color: #0000BB">$num2 </span><span style="color: #007700">= -</span><span style="color: #0000BB">0.000005</span><span style="color: #007700">; </span><span style="color: #FF8000">// (string) -0.000005 =&gt; '-5.05E-6'<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">bcadd</span><span style="color: #007700">(</span><span style="color: #0000BB">$num1</span><span style="color: #007700">, </span><span style="color: #0000BB">$num2</span><span style="color: #007700">, </span><span style="color: #0000BB">6</span><span style="color: #007700">); </span><span style="color: #FF8000">// =&gt; '0.000000'<br /><br /></span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_NUMERIC</span><span style="color: #007700">, </span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">); </span><span style="color: #FF8000">// utilise une virgule décimale<br /></span><span style="color: #0000BB">$num2 </span><span style="color: #007700">= </span><span style="color: #0000BB">1.2</span><span style="color: #007700">; </span><span style="color: #FF8000">// (string) 1.2 =&gt; '1,2'<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">bcsub</span><span style="color: #007700">(</span><span style="color: #0000BB">$num1</span><span style="color: #007700">, </span><span style="color: #0000BB">$num2</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">); </span><span style="color: #FF8000">// =&gt; '0.0'<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </div>
 </div>
 

 









 








 






<ul class="chunklist chunklist_book"><li><a href="bc.setup.php">Installation/Configuration</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="bc.installation.php">Installation</a></li><li><a href="bc.configuration.php">Configuration &agrave; l'ex&eacute;cution</a></li></ul></li><li><a href="ref.bc.php">Fonctions BC Math</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.bcadd.php">bcadd</a> — Additionne deux nombres de grande taille</li><li><a href="function.bcceil.php">bcceil</a> — Arrondit au sup&eacute;rieur un nombre de pr&eacute;cision arbitraire</li><li><a href="function.bccomp.php">bccomp</a> — Compare deux nombres de grande taille</li><li><a href="function.bcdiv.php">bcdiv</a> — Divise deux nombres de grande taille</li><li><a href="function.bcdivmod.php">bcdivmod</a> — Renvoie le quotient et le reste d'un nombre de pr&eacute;cision arbitraire</li><li><a href="function.bcfloor.php">bcfloor</a> — Arrondit &agrave; l'inf&eacute;rieur un nombre de pr&eacute;cision arbitraire</li><li><a href="function.bcmod.php">bcmod</a> — Retourne le reste d'une division entre nombres de grande taille</li><li><a href="function.bcmul.php">bcmul</a> — Multiplie deux nombres de grande taille</li><li><a href="function.bcpow.php">bcpow</a> — &Eacute;l&egrave;ve un nombre &agrave; une puissance donn&eacute;e</li><li><a href="function.bcpowmod.php">bcpowmod</a> — Calcule le reste modulo d'un nombre &eacute;lev&eacute; &agrave; une puissance</li><li><a href="function.bcround.php">bcround</a> — Arrondit un nombre de pr&eacute;cision arbitraire</li><li><a href="function.bcscale.php">bcscale</a> — D&eacute;finit ou r&eacute;cup&egrave;re la pr&eacute;cision par d&eacute;faut pour toutes les fonctions bc math</li><li><a href="function.bcsqrt.php">bcsqrt</a> — R&eacute;cup&egrave;re la racine carr&eacute;e d'un nombre de grande taille</li><li><a href="function.bcsub.php">bcsub</a> — Soustrait un nombre de grande taille d'un autre</li></ul></li><li><a href="class.bcmath-number.php">BcMath\Number</a> — La classe BcMath\Number<ul class="chunklist chunklist_book chunklist_children"><li><a href="bcmath-number.add.php">BcMath\Number::add</a> — Ajouter un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.ceil.php">BcMath\Number::ceil</a> — Arrondit au sup&eacute;rieur un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.compare.php">BcMath\Number::compare</a> — Compare deux nombres de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.construct.php">BcMath\Number::__construct</a> — Cr&eacute;e un objet BcMath\Number</li><li><a href="bcmath-number.div.php">BcMath\Number::div</a> — Divise par un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.divmod.php">BcMath\Number::divmod</a> — Renvoie le quotient et le modulo d'un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.floor.php">BcMath\Number::floor</a> — Arrondit &agrave; l'inf&eacute;rieur un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.mod.php">BcMath\Number::mod</a> — Renvoie le modulo d'un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.mul.php">BcMath\Number::mul</a> — Multiplie un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.pow.php">BcMath\Number::pow</a> — &Eacute;l&egrave;ve un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.powmod.php">BcMath\Number::powmod</a> — &Eacute;l&egrave;ve un nombre de pr&eacute;cision arbitraire, r&eacute;duit par un modulo sp&eacute;cifi&eacute;</li><li><a href="bcmath-number.round.php">BcMath\Number::round</a> — Arrondit un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.serialize.php">BcMath\Number::__serialize</a> — S&eacute;rialise un objet BcMath\Number</li><li><a href="bcmath-number.sqrt.php">BcMath\Number::sqrt</a> — Renvoie la racine carr&eacute;e d'un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.sub.php">BcMath\Number::sub</a> — Soustrait un nombre de pr&eacute;cision arbitraire</li><li><a href="bcmath-number.tostring.php">BcMath\Number::__toString</a> — Convertit un BcMath\Number en cha&icirc;ne</li><li><a href="bcmath-number.unserialize.php">BcMath\Number::__unserialize</a> — D&eacute;s&eacute;rialise un param&egrave;tre de donn&eacute;es en un objet BcMath\Number</li></ul></li></ul></div><?php manual_footer($setup); ?>