array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.fmod.php', 1 => 'fmod', ), 'up' => array ( 0 => 'ref.math.php', 1 => 'Math 函数', ), 'prev' => array ( 0 => 'function.floor.php', 1 => 'floor', ), 'next' => array ( 0 => 'function.hexdec.php', 1 => 'hexdec', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/math/functions/fmod.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
fmod — 返回除法的浮点数余数
返回被除数(num1
)除以除数(num2
)所得的浮点数余数。余数(r)的定义是:num1
= i * num2 + r,其中 i 是整数。如果 num2
是非零值,则 r 和
num1
的符号相同并且其数量值小于
num2
。
num1
被除数
num2
除数
num1
/num2
的浮点数余数。
示例 #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
?>