Home  >  Article  >  Backend Development  >  How to use php fmod function?

How to use php fmod function?

藏色散人
藏色散人Original
2019-05-29 15:16:373311browse

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.

How to use php fmod function?

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn