Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85726 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79934 invoked from network); 3 Apr 2015 21:04:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2015 21:04:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.207 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.207 imap2-2.ox.privateemail.com Received: from [192.64.116.207] ([192.64.116.207:46938] helo=imap2-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/F6-23347-6700F155 for ; Fri, 03 Apr 2015 16:04:55 -0500 Received: from localhost (localhost [127.0.0.1]) by imap2.ox.privateemail.com (Postfix) with ESMTP id 90DEA8C007B; Fri, 3 Apr 2015 17:04:51 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from imap2.ox.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jVYFjGdJgnDo; Fri, 3 Apr 2015 17:04:51 -0400 (EDT) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by imap2.ox.privateemail.com (Postfix) with ESMTPSA id 6F21F8C0075; Fri, 3 Apr 2015 17:04:50 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: Date: Fri, 3 Apr 2015 22:04:48 +0100 Cc: Levi Morrison , PHP Internals , Nikita Popov Content-Transfer-Encoding: quoted-printable Message-ID: <2A19F8F0-0F08-4F9C-941A-B6C3607F5CE9@ajf.me> References: To: Dmitry Stogov X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV] Fix division by zero to throw exception From: ajf@ajf.me (Andrea Faulds) Hi, > On 3 Apr 2015, at 21:34, Dmitry Stogov wrote: >=20 > 3) One more problem is modulo :( >=20 > $ sapi/cli/php -n -r "var_dump(1 % 0);" >=20 > 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 = operation 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, = just returning different parts of the result. An exception being = produced by both would seem reasonable. Thanks. -- Andrea Faulds http://ajf.me/