How to use php fmod function?

藏色散人
Release: 2023-02-22 22:06:02
Original
3313 people have browsed it

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)
Copy after login

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
?>
Copy after login

Output:

1
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template