PHP - fmod
Trieda
Metóda - fmod
(PHP 4 >= 4.2.0, PHP 5, PHP 7)
This function is similar to the % (modulo) operator, but this function returns the floating point remainder.
Procedurálne
- function fmod (float $x, float $y) : float
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $x | float | The dividend. | |
| $y | float | The divisor. |
Mávratovej hodnoty
Vracia: float
The decimal modulus of a division of the dividend x by the divisor y represented as floating point number (float).
Príklady
<?php
echo ("11 mod 7 = " . fmod(11, 7). "<br>");
echo ("2.5 mod 2 = " . fmod(2.5, 2). "<br>");
echo ("7 mod 4 = " . fmod(7, 4). "<br>");
echo ("11 mod 0.3 = " . fmod(11, 0.3). "<br>");
This example outputs (if viewed from a web browser):
11 mod 7 = 4 2.5 mod 2 = 0.5 7 mod 4 = 3 11 mod 0.3 = 0.2
