| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
Subject: Compatibility for older PHP
Text: Equivalent for versions before 8.0. Handles the sign of zero for INF results.
<?php
if (!function_exists('fdiv')) {
function fdiv(float $a, float $b): float
{
if (is_nan($a) || is_nan($b)) return NAN;
if ($b != 0.0) return $a / $b;
if ($a == 0.0) return NAN;
$check = function ($v) {
if ($v > 0) return 1;
if ($v < 0) return -1;
return pack('d', (float)$v) === pack('d', 0.0) ? 1 : -1;
};
return ($check($a) === $check($b)) ? INF : -INF;
}
}
?>
----
Server IP: 206.189.2.9
Probable Submitter: 178.17.2.163
----
Manual Page -- https://php.net/manual/en/function.fdiv.php
Edit -- https://main.php.net/note/edit/130613
Del: integrated -- https://main.php.net/note/delete/130613/integrated
Del: useless -- https://main.php.net/note/delete/130613/useless
Del: bad code -- https://main.php.net/note/delete/130613/bad+code
Del: spam -- https://main.php.net/note/delete/130613/spam
Del: non-english -- https://main.php.net/note/delete/130613/non-english
Del: in docs -- https://main.php.net/note/delete/130613/in+docs
Del: other reasons-- https://main.php.net/note/delete/130613
Reject -- https://main.php.net/note/reject/130613
Search -- https://main.php.net/manage/user-notes.php