Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83701 invoked from network); 3 Apr 2015 21:15:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2015 21:15:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.160.172 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.160.172 mail-yk0-f172.google.com Received: from [209.85.160.172] ([209.85.160.172:35874] helo=mail-yk0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/C7-23347-1030F155 for ; Fri, 03 Apr 2015 16:15:46 -0500 Received: by ykcn8 with SMTP id n8so31639176ykc.3 for ; Fri, 03 Apr 2015 14:15:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=J0Kaoq3OZr/Jl5NkNtSn2B//LMwkgEXV/zUfHtljKbY=; b=aahxrIknKY+fw5F4O/vk+m0K/ysKYgAMn9BfdLDfHel0iBtLsC56or9OMwxIUlm5JE A8TylNT8HkUOXdPqsQZ+n2ayQEcWMlXj8Y4/4ooIKWNMEeMIpk7f4kwzB93dKk1uLPQc LumoCQIuLzll8TmcOadaLRl8Nu1p0568hb0jzH/3D8Ndya9yVJq+3I5RnYMJDeuCfAt4 jIcWvMPG1z5tIqdNBwVDdKaReYI3nH6Wg7hSwnM8mB7I0tinGi4a1FcSOBHj2srlSpAx rCg1YPDbhHgvgfPOLfa7JWp3fcG912nFxnLM1vgy4Na2xAfeyR1m143B7pnow7CgrCe5 XV0A== X-Gm-Message-State: ALoCoQm4GcMsNBXPWUTjC19k6vW8XWGgmjRV5aJey1pyqVJTyfsbvWSPWEkHXJHNooxFc66nsdtTNBKjGmHkt+5Zr7QF8wkXq/6Lh35bfsWsFJheknm7B08FGw9VQMV2S0K/hH0Ny67vaA6ho7LTILo0eRVmC7Ttaw== MIME-Version: 1.0 X-Received: by 10.52.61.137 with SMTP id p9mr2376482vdr.68.1428095743246; Fri, 03 Apr 2015 14:15:43 -0700 (PDT) Received: by 10.52.248.36 with HTTP; Fri, 3 Apr 2015 14:15:43 -0700 (PDT) In-Reply-To: <2A19F8F0-0F08-4F9C-941A-B6C3607F5CE9@ajf.me> References: <2A19F8F0-0F08-4F9C-941A-B6C3607F5CE9@ajf.me> Date: Sat, 4 Apr 2015 00:15:43 +0300 Message-ID: To: Andrea Faulds Cc: Levi Morrison , PHP Internals , Nikita Popov Content-Type: multipart/alternative; boundary=001a1136b5747b60960512d87369 Subject: Re: [PHP-DEV] Fix division by zero to throw exception From: dmitry@zend.com (Dmitry Stogov) --001a1136b5747b60960512d87369 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Apr 4, 2015 at 12:04 AM, Andrea Faulds wrote: > Hi, > > > On 3 Apr 2015, at 21:34, Dmitry Stogov wrote: > > > > 3) One more problem is modulo :( > > > > $ sapi/cli/php -n -r "var_dump(1 % 0);" > > > > Warning: Division by zero in Command line code on line 1 > > bool(false) > > Hmm, modulo is a more difficult one. Since it=E2=80=99s an integer-only o= peration > in PHP, producing INF doesn=E2=80=99t make sense. It also doesn=E2=80=99t= make sense > mathematically. I think the most sensible thing to do here would be to > throw an exception. > > On the same note, the new function intdiv() is the counterpart to % for > obtaining the quotient (% produces the remainder). It currently does the > same thing as % and / division and produces FALSE with a warning. If % is > changed, intdiv() should be too, because they are the same operation, jus= t > returning different parts of the result. An exception being produced by > both would seem reasonable. > Cool :) 4) fix intdiv() to throw exception. Thanks. Dmitry, > > Thanks. > > -- > Andrea Faulds > http://ajf.me/ > > > > > --001a1136b5747b60960512d87369--