Req #71306 [ReO->Csd]: Remove Division by zero warning from "/" operator
| From: | nikic@php.net | Date: | Thu, 09 Jan 2020 11:50:37 +0000 |
| Subject: | Req #71306 [ReO->Csd]: Remove Division by zero warning from "/" operator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224809@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71306&edit=1
ID: 71306
Updated by: nikic@php.net
Reported by: hungry dot rahly at gmail dot com
Summary: Remove Division by zero warning from "/" operator
-Status: Re-Opened
+Status: Closed
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: irrelevant
PHP Version: irrelevant
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
This has been changed to throw DivisionByZeroError in PHP 8. fdiv() is available to perform a silent
division. See https://wiki.php.net/rfc/engine_warnings.
Previous Comments:
------------------------------------------------------------------------
[2016-03-22 20:14:13] ajf@php.net
Interestingly fmod() doesn't produce a warning here, so if we got rid of the warning for
/ then we'd bring the two into alignment.
------------------------------------------------------------------------
[2016-03-10 13:08:16] axiac dot ro at gmail dot com
It would be great to have this behaviour (who throws the exception and who doesn't) explained
in the documentation of the DivisionByZeroError exception.
I submitted a patch on the documentation site that adds this information.
------------------------------------------------------------------------
[2016-01-09 00:24:18] yohgaki@php.net
Make this a change request.
------------------------------------------------------------------------
[2016-01-08 00:49:20] hungry dot rahly at gmail dot com
Then a removal of the warning would be best, because with the warning, you are saying there is a
problem, when in fact, there isn't.
------------------------------------------------------------------------
[2016-01-08 00:43:06] bwoebi@php.net
This indeed is expected behavior; the only possible thing eventually subject to change in future is
whether the warning will be removed.
But a DivisionByZeroError is definitely not suitable here as divisions by zero are handled like
floating point divisions. (Yielding ±INF or NaN)
Just for integer divisions (intdiv) and modulo, there's no valid result, hence an exception is
then thrown (instead of false like before).
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=71306
--
Edit this bug report at https://bugs.php.net/bug.php?id=71306&edit=1