Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75639 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18160 invoked from network); 17 Jul 2014 06:10:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2014 06:10:00 -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.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:58792] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/81-09067-5B867C35 for ; Thu, 17 Jul 2014 02:09:59 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 4EACFB0008E; Thu, 17 Jul 2014 02:09:54 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 272KmAsdG4Gp; Thu, 17 Jul 2014 02:09:54 -0400 (EDT) Received: from [192.168.0.15] (unknown [90.210.122.167]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 8CADDB0008B; Thu, 17 Jul 2014 02:09:52 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Thu, 17 Jul 2014 07:09:49 +0100 Cc: Tjerk Meesters , bishop@php.net, PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <1240076591.91249.1405564441970.open-xchange@app1.ox.registrar-servers.com> To: Sara Golemon X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] intdiv() From: ajf@ajf.me (Andrea Faulds) On 17 Jul 2014, at 04:23, Sara Golemon wrote: > Do we need a new operator for that? It feels un-php to me, and the > kind of problem bigint objects should be meant to solve. On the other > hand, having $a/$b !=3D $a/$b (Off by more than 100 in this instance). > But back on the first hand, that's consistent with other operations on > large floats anyway. PHP_INT_MAX + 1 !=3D One more than PHP_INT_MAX, Actually, my bigints RFC would retain the existing / behaviour (float = result if non-zero remainder), so to avoid an unnecessary divisibility = check or to deliberately ignore the remainder you=92d need some sort of = integer division operator there. On the other hand, that RFC would also = see ext/gmp always available, I suppose. Of course this isn=92t what = ext/gmp does *now*, where it makes / be integer division (yuck). I think = the / operator=92s behaviour makes complete sense and Python 3 actually = does exactly the same thing as PHP here, because what / does is the most = intuitive thing. I suppose a function alone might do, but it feels a bit lacking to me = not to have an operator for this. I=92d also argue it=92s not really = un-PHP to add this, we already have the mod (%) operator and the bitwise = operators also operate only on integers. Furthermore division ignoring = the remainder is actually a fairly common use case (time for example), = so I think there should be some way to do that when you need it. I = wonder if the intent there might be clearer, too, than using floor() or = (int). -- Andrea Faulds http://ajf.me/