PHPverse 2025

Voting

: max(six, one)?
(Example: nine)

The Note You're Voting On

jphansen at uga dot edu
20 years ago
fmod() does not mirror a calculator's mod function. For example, fmod(.25, .05) will return .05 instead of 0 due to floor(). Using the aforementioned example, you may get 0 by replacing floor() with round() in a custom fmod().

<?
function fmod_round($x, $y) {
$i = round($x / $y);
return $x - $i * $y;
}

var_dump(fmod(.25, .05)); // float(0.05)
var_dump(fmod_round(.25, .05)); // float(0)
?>

<< Back to user notes page

To Top