The fmod Function
The fmod
function calculates the fractional remainder
of division.
Syntax
fmod(dividend, divisor);
Example
Let's find the remainder of dividing 4
by 1.2
:
<?php
echo fmod(4, 1.2);
?>
Execution result:
0.4
Example
Compare with what the % operator will output:
<?php
echo 4 % 1.2;
?>
Execution result:
0
See Also
-
lesson division remainder,
which explains the%
operator -
function
round
,
which rounds fractions according to mathematical rules -
function
ceil
,
which rounds fractions up -
function
floor
,
which rounds fractions down