On Thu, Aug 25, 2022, at 3:16 PM, Rowan Tommins wrote:

> But then we face the awkward asymmetry of the current functionality:
>
> intdiv() - Integer division
> / - Floating-point division
> % - Integer modulus
> fmod() - Floating-point modulo
>
> Apparently as of PHP 8.0, there is also an fdiv() function, but the 
> manual doesn't currently explain why it exists, and whether it will 
> always give the same result as / (and if not, why not?)

/ in PHP 8.0+ throws DivideByZeroError if you divide by 0.  Prior versions, it 
was a fatal error.

fdiv() returns a NAN or INF constant for division by 0.

echo fdiv(5, 0); // INF
echo fdiv(-5, 0); // -INF
echo fdiv(0, 0); // NAN

This was a Nikita special.

Yes, the docs should likely be updated.

--Larry Garfield

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to