fmod(): floating-point remainder of division

Get a floating-point remainder with fmod()

Use fmod() when the dividend or divisor is a floating-point value. For integer modulus, use the % operator instead.

$remainder = fmod(5.7, 1.3);
echo $remainder; // approximately 0.5

The sign of a non-zero remainder follows the dividend. If the divisor is zero, fmod() returns NAN.

<?Php
echo fmod(5,2); // Output 1
echo "<br>";
echo fmod(10,2); // Output 0 
echo "<br>";
echo fmod(13,2); // Output is 1
echo "<br>";
echo fmod(6,3); // Output is 0
?>
Syntax
float fmod(float $num1, float $num2)

$num1 is the dividend and $num2 is the divisor. The result is the floating-point remainder after division.

Zero divisor: fmod($num1, 0.0) returns NAN. Use is_nan() if a zero divisor is possible.


Math Functions intdiv() Integer division (quotient) of a number
base_convert(): Convert number From any base to other


Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer