Re: [RFC] intdiv()
| From: | Sara Golemon | Date: | Thu, 17 Jul 2014 02:41:33 +0000 |
| Subject: | Re: [RFC] intdiv() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75629@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()?
>
It does, but it returns the float truncated result of division. I'm
suggesting having it to integer division. So you'd do: $a / $b and
it's be smart enough to do the right method.
>> If we're really set on adding a new operator, I'd vote for something
>> which provides dividend *and* remainder in some way. (Useful for time
>> arithmetic, for example)
>> In all seriousness, you could just have the compiler optimise using % and %%
> successively with the same operands to just be a single division, if that's
> possible.
>
Assuming you meant / and %, then probably in opcache+'s optimizer.
-Sara