Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86942 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6854 invoked from network); 29 Jun 2015 16:14:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2015 16:14:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.175 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.175 mail-wi0-f175.google.com Received: from [209.85.212.175] ([209.85.212.175:34752] helo=mail-wi0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/51-25761-7DE61955 for ; Mon, 29 Jun 2015 12:14:16 -0400 Received: by wiar9 with SMTP id r9so9176593wia.1 for ; Mon, 29 Jun 2015 09:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8jiqkKeFeyhGDRKvNw9PvBvDg8JXQ83XA6V8qI3kQG4=; b=h1ikavlcEWmP8bWcEWFS1dl00nj2fTTcEmQQ/5j73mX/3ikHe8HcgyBflXIClAz8by 9kCQrNASY89KxD8NqhAAfO2m7UimmY/tkrkbX+RjnUz0hoAo4sOP4kq01owEK21luNSB sUNdZ8bG3S/u9k71VY6IMoSzndjwS8W5m9+wmbPsOLKrmLJYiwmvstoWOYdgYOcmc5Wq C6IgAe6XYBjC3EUx5n+eziI1uzzgiDOtA7sbztqDXFjjA7zvOxg9pslpRYXTACW2XzLz LUUpxKRQwby9ToteayJOteBEusBLe4OQMWh/5mCtOFwIP+FMVDzGx8clPaLAJ1bUkg+h vEbw== MIME-Version: 1.0 X-Received: by 10.194.184.140 with SMTP id eu12mr29524960wjc.78.1435594452627; Mon, 29 Jun 2015 09:14:12 -0700 (PDT) Received: by 10.27.179.96 with HTTP; Mon, 29 Jun 2015 09:14:12 -0700 (PDT) In-Reply-To: References: <33BCE1D0-BA6D-464C-B23D-69AF71356111@ajf.me> <3932E76B-DC75-40CD-8B1A-B84F387707CC@ajf.me> Date: Mon, 29 Jun 2015 18:14:12 +0200 Message-ID: To: Bob Weinand Cc: Dmitry Stogov , Andrea Faulds , PHP Internals , Anatol Belski Content-Type: multipart/alternative; boundary=047d7bacc2c063f8000519aa6138 Subject: Re: [PHP-DEV] Fix division by zero to throw exception (round 2) From: nikita.ppv@gmail.com (Nikita Popov) --047d7bacc2c063f8000519aa6138 Content-Type: text/plain; charset=UTF-8 On Mon, Jun 29, 2015 at 5:54 PM, Bob Weinand 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 : > > 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 --047d7bacc2c063f8000519aa6138--