Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 9088

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Introduction</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.bc.html">BC Math</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="bc.setup.html">Installing/Configuring</a></div>
 <div class="up"><a href="book.bc.html">BC Math</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intro.bc" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="para">
    For arbitrary precision mathematics PHP offers the Binary Calculator which
   supports numbers of any size and precision up to <em>2147483647</em> (or <em>0x7FFFFFFF</em>) decimals,
   if there is sufficient memory, represented as strings.
  </p>
  <div class="caution"><strong class="caution">Caution</strong>
   <p class="para">
    Passing values of type <span class="type"><a href="language.types.float.html" class="type float">float</a></span> to a BCMath function which expects
    a <span class="type"><a href="language.types.string.html" class="type string">string</a></span> as operand may not have the desired effect due to the
    way PHP converts <span class="type"><a href="language.types.float.html" class="type float">float</a></span> values to <span class="type"><a href="language.types.string.html" class="type string">string</a></span>, namely
    that the <span class="type"><a href="language.types.string.html" class="type string">string</a></span> may be in exponential notation (what is not
    supported by BCMath), and that the decimal separator is locale dependend
    (while BCMath always expects a decimal point).
   </p>
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$num1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;(string)&nbsp;0&nbsp;=&gt;&nbsp;'0'<br /></span><span style="color: #0000BB">$num2&nbsp;</span><span style="color: #007700">=&nbsp;-</span><span style="color: #0000BB">0.000005</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;(string)&nbsp;-0.000005&nbsp;=&gt;&nbsp;'-5.05E-6'<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">bcadd</span><span style="color: #007700">(</span><span style="color: #0000BB">$num1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$num2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">6</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;=&gt;&nbsp;'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">,&nbsp;</span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;uses&nbsp;a&nbsp;decimal&nbsp;comma<br /></span><span style="color: #0000BB">$num2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1.2</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;(string)&nbsp;1.2&nbsp;=&gt;&nbsp;'1,2'<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">bcsub</span><span style="color: #007700">(</span><span style="color: #0000BB">$num1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$num2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;=&gt;&nbsp;'0.0'<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.bc.html">BC Math</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="bc.setup.html">Installing/Configuring</a></div>
 <div class="up"><a href="book.bc.html">BC Math</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>