<!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>Returns the floating point remainder (modulo) of the division of the arguments</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.floor.html">floor</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.getrandmax.html">getrandmax</a></div> <div class="up"><a href="ref.math.html">Math Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.fmod" class="refentry"> <div class="refnamediv"> <h1 class="refname">fmod</h1> <p class="verinfo">(PHP 4 >= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">fmod</span> — <span class="dc-title">Returns the floating point remainder (modulo) of the division of the arguments</span></p> </div> <div class="refsect1 description" id="refsect1-function.fmod-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">float</span> <span class="methodname"><strong>fmod</strong></span> ( <span class="methodparam"><span class="type">float</span> <code class="parameter">$x</code></span> , <span class="methodparam"><span class="type">float</span> <code class="parameter">$y</code></span> )</div> <p class="para rdfs-comment"> Returns the floating point remainder of dividing the dividend (<em><code class="parameter">x</code></em>) by the divisor (<em><code class="parameter">y</code></em>). The remainder (<var class="varname"><var class="varname">r</var></var>) is defined as: x = i * y + r, for some integer <var class="varname"><var class="varname">i</var></var>. If <em><code class="parameter">y</code></em> is non-zero, <var class="varname"><var class="varname">r</var></var> has the same sign as <em><code class="parameter">x</code></em> and a magnitude less than the magnitude of <em><code class="parameter">y</code></em>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.fmod-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">x</code></em></span> <dd> <p class="para"> The dividend </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">y</code></em></span> <dd> <p class="para"> The divisor </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.fmod-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The floating point remainder of <em><code class="parameter">x</code></em>/<em><code class="parameter">y</code></em> </p> </div> <div class="refsect1 examples" id="refsect1-function.fmod-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3460"> <p><strong>Example #1 Using <span class="function"><strong>fmod()</strong></span></strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$x </span><span style="color: #007700">= </span><span style="color: #0000BB">5.7</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$y </span><span style="color: #007700">= </span><span style="color: #0000BB">1.3</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">fmod</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">, </span><span style="color: #0000BB">$y</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// $r equals 0.5, because 4 * 1.3 + 0.5 = 5.7<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.floor.html">floor</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.getrandmax.html">getrandmax</a></div> <div class="up"><a href="ref.math.html">Math Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>