Home > Article > Backend Development > How to use php fmod function?
php The fmod function is used to return the floating-point remainder of division. Its syntax is fmod(x,y). The parameter x is required and refers to one number. y is required and refers to another number.
#php How to use fmod function?
Definition and usage
fmod() function returns the floating-point remainder of division.
Syntax
fmod(x,y)
Parameters
x Required. A number.
y Required. A number.
Description
Returns the floating-point remainder obtained by dividing the dividend (x) by the divisor (y). The definition of remainder (r) is: x = i * y r, where i is an integer. If y is nonzero, then r and x have the same sign and their magnitude is less than y .
Example
In this example, we will use the fmod() function to return the remainder of 5/2:
<?php $r = fmod(5,2); echo $r ?>
Output:
1
The above is the detailed content of How to use php fmod function?. For more information, please follow other related articles on the PHP Chinese website!