Re: Fix division by zero to throw exception (round 2)
| From: | Bob Weinand | Date: | Mon, 29 Jun 2015 15:54:33 +0000 |
| Subject: | Re: Fix division by zero to throw exception (round 2) | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-86941@lists.php.net to get a copy of this message | ||
I would like to bring this topic back up, as there were users confused with it and it's
absolutely not consistent what we have now.
See also https://bugs.php.net/bug.php?id=69957
<https://bugs.php.net/bug.php?id=69957>
(As I thought it was non-intentional, I went ahead and "fixed" it, was reverted later,
hence discussing that now here.)
So, looks like there was some quick decisions and discussion I totally had missed.
What we have now is:
> Am 03.04.2015 um 23:13 schrieb Dmitry Stogov <dmitry@zend.com>:
>
> So the summary:
>
> 1) division by zero produces a warning and +/-INF IS_DOUBLE. Compile-time
> evaluation is disabled.
>
> 3) Modulo by zero produces Exception.Compile-time evaluation is disabled.
Why? Why do we change the one but not the other?
Why does 0 % 0 throw an Exception, but 0 / 0 NAN?
Why does 1 % 0 throw an Exception, but 1 / 0 INF?
I'd like to either properly return 0, INF or NAN in both cases or in none.
Having different rules for so similar operations is non-sense, I think. It just is inconsistent and
causes confusion.
Bob