fdiv() function

  107361
October 2, 2019 13:14 nikita.ppv@gmail.com (Nikita Popov)
Hi internals,

I would like to add an fdiv() function in PHP 8, implemented in
https://github.com/php/php-src/pull/4769.

Per https://wiki.php.net/rfc/engine_warnings the main division operation
will switch to throwing DivisionByZeroError on division by zero. However, I
think it is important to expose a division with IEEE-754 semantics for
division by zero for the use-cases that do need this. It is fairly tricky
and not very efficient to implement this by hand in userland code,
primarily due to correct handling for negative zero.

The fdiv() function will perform a floating-point division while treating
division by zero as a perfectly legal operation, and will not emit any kind
of diagnostic in that case. Instead it will return the INF/-INF/NAN result
mandated by IEEE-754. It mirrors the existing fmod() function.

Does anyone see an issue with this addition?

Regards,
Nikita
  107373
October 4, 2019 20:28 me@kelunik.com (Niklas Keller)
Hi Nikita,

> The fdiv() function will perform a floating-point division while treating > division by zero as a perfectly legal operation, and will not emit any kind > of diagnostic in that case. Instead it will return the INF/-INF/NAN result > mandated by IEEE-754. It mirrors the existing fmod() function.
I'd prefer floatdiv() as name matching intdiv(), but wasn't aware fmod() is already a thing. So now I think fdiv() might be the slightly more consistent name. Regards, Niklas