Re: [RFC] intdiv()

From: Date: Thu, 17 Jul 2014 03:23:43 +0000
Subject: Re: [RFC] intdiv()
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-75631@lists.php.net to get a copy of this message
On Wed, Jul 16, 2014 at 7:34 PM, Andrea Faulds <ajf@ajf.me> 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. -Sara

« previous php.internals (#75631) next »