3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isMultipleOf(float $number, float $divisor) { $modulus = ($number - round($number / $divisor) * $divisor); $precision = 0.0000000001; if (-$precision < $modulus && $modulus < $precision) { return 0.0; } return $modulus; } function test(float $value, float $multiple, $expected) { if ((isMultipleOf($value, $multiple) == 0.0) !== $expected) { var_dump($value, $multiple, $expected); } } test(400.01, 0.01, true); test(400.01, 3, false); test(9007199254740991.00000000000000, 1, true); test(900719925474099166666.00000000000000, 1, true); test(2.00000000000000, 1, true); test(2, 1, true);

preferences:
28.07 ms | 405 KiB | 5 Q