Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75634 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7425 invoked from network); 17 Jul 2014 04:13:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2014 04:13:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.177 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.177 mail-lb0-f177.google.com Received: from [209.85.217.177] ([209.85.217.177:44780] helo=mail-lb0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/23-19007-47D47C35 for ; Thu, 17 Jul 2014 00:13:41 -0400 Received: by mail-lb0-f177.google.com with SMTP id s7so1271214lbd.8 for ; Wed, 16 Jul 2014 21:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=M/IgNBQEl0fqzwdYsR8t8g1hCPbBEVOGW8sgIDIhlsU=; b=kSuDM8rEClulSa/gPZTibWhgQ5LswcHhWWA3vqDUXvcHpZPFwc18U00Tjc5xPRYq8W ZhHusa0v6HW9e0iT+KerGLJnYyD7uwSE4FBSuzzkrm818xJRBoTQ3JTTjGjDFyNvRk+h sU4+VjMo2OTQlZEwhHM7+YSakdcxK5tkY6iJYeR9q1gCpo+GLbAkxxJO5y0684D8u5YY CVCrXa45x9J54748H02ERtXrgEoTc1s+Uq5ZwSu8O/rk55C5i8N2DqHP14dw13XJGLis LzR5hsCtKY6zdNO480xp6C43LLLgTE9t/f+hiWjOVJNDC7yMHqyYEXZn2b4TdbdQ8eMX AfWA== X-Received: by 10.112.144.162 with SMTP id sn2mr21915570lbb.49.1405570417456; Wed, 16 Jul 2014 21:13:37 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.128.202 with HTTP; Wed, 16 Jul 2014 21:12:57 -0700 (PDT) In-Reply-To: References: <1240076591.91249.1405564441970.open-xchange@app1.ox.registrar-servers.com> Date: Thu, 17 Jul 2014 13:12:57 +0900 X-Google-Sender-Auth: m6A8z8YzI0vJGRiy_zs0Yox5v_g Message-ID: To: Sara Golemon Cc: Andrea Faulds , Tjerk Meesters , bishop@php.net, PHP internals Content-Type: multipart/alternative; boundary=047d7b3a8776707e6204fe5bdd29 Subject: Re: [PHP-DEV] [RFC] intdiv() From: yohgaki@ohgaki.net (Yasuo Ohgaki) --047d7b3a8776707e6204fe5bdd29 Content-Type: text/plain; charset=UTF-8 Hi all, On Thu, Jul 17, 2014 at 12:23 PM, Sara Golemon wrote: > On Wed, Jul 16, 2014 at 7:34 PM, Andrea Faulds wrote: > > What are you suggesting you do for an integer division, then? ($a - ($a > % $b)) / > > $ b? The division operator already returns an integer. Or should I just > use > > intdiv()? > > > Wow. I just finally understood what your RFC was going for. I thought > you were trying to cover the case where ($a%$b)==0, but you're not, > you're trying to do truncated integer division regardless of > remainder. I also missed the fact that div_function does the right > thing already as well. My bad for emailing from the bus. > > Okay, that's another animal entirely. > > 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 != $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 != One more than PHP_INT_MAX, > for example. It would be better to implement it as functions like GMP, BCMath. http://jp2.php.net/manual/en/ref.gmp.php http://jp2.php.net/manual/en/ref.bc.php Since we have prefix_name() naming standard, functions name should int_div() int_mod() int_mul() etc It's consistent with standard and existing functions. I understand functions are inconvenient, but they will have limited usage. We may decide to have operators later, if we really need them. BTW, I'll be +1 for int_div(), etc. Undecided for operators, -1 probably. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --047d7b3a8776707e6204fe5bdd29--