On Mon, Jun 29, 2015 at 5:54 PM, Bob Weinand <bobw...@hotmail.com> wrote:
> 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 (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 <dmi...@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 > I agree with Bob here: It would be nice if the behavior of division and modulus lined up. I'd like to add that the choice of returning Inf and additionally throwing a warning is particularly weird. While using Inf as the result of division by zero makes sense in some contexts (mainly scientific computing), in these contexts it's also a perfectly normal operation that would not generate a warning. If we want to use Inf we should remove the warning as well. However it should be noted that PHP is not well known for it's application in scientific computing and for our purposes the exception is likely more useful. Nikita