PHP fmod() Function – Returns Floating‑Point Remainder of Division
This article explains PHP's fmod() function, detailing its syntax, parameter meanings, return value, and provides a practical code example that demonstrates how it calculates the floating‑point remainder of a division operation.
The article describes the PHP fmod() function, which returns the floating‑point remainder of dividing one number by another.
Syntax float fmod ( float $x, float $y ) Parameters $x – the dividend. $y – the divisor (must be non‑zero).
Return value
The function returns the remainder r such that x = i * y + r, where i is an integer; the sign of r matches the sign of x and its absolute value is less than y.
Example
<?php
$x = 5.7;
$y = 1.3;
$r = fmod($x, $y);
// $r equals 0.5, because 4 * 1.3 + 0.5 = 5.7
?>The output comment shows that $r equals 0.5, confirming the function’s behavior.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
