= 4.2.0, PHP 5, PHP 7, PHP 8)fmod — 返回除法的浮點(diǎn)數(shù)余數(shù)說明fmod(float $x, float $y): float返回被除數(shù)(x)除以除數(shù)(y)所得的浮點(diǎn)數(shù)余數(shù)。余數(shù)(r)的定義是:x = i * y + r,其中 i 是整數(shù)。如果">

fmod

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

fmod返回除法的浮點(diǎn)數(shù)余數(shù)

說明

fmod(float $x, float $y): float

返回被除數(shù)(x)除以除數(shù)(y)所得的浮點(diǎn)數(shù)余數(shù)。余數(shù)(r)的定義是:x = i * y + r,其中 i 是整數(shù)。如果 y 是非零值,則 rx 的符號(hào)相同并且其數(shù)量值小于 y。

參數(shù)

x

被除數(shù)

y

除數(shù)

返回值

x/y的浮點(diǎn)數(shù)余數(shù)。

范例

示例 #1 fmod() 的使用

<?php
$x 
5.7;
$y 1.3;
$r fmod($x$y);
// $r equals 0.5, because 4 * 1.3 + 0.5 = 5.7
?>