Re: [RFC] intdiv()
| From: | Andrea Faulds | Date: | Thu, 17 Jul 2014 02:34:01 +0000 |
| Subject: | Re: [RFC] intdiv() | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-75628@lists.php.net to get a copy of this message | ||
> On July 17, 2014 at 3:17 AM Sara Golemon <pollita@php.net> wrote:
>
> All that said, *I* think the tradeoff of an extra idivq in the
> (probably more common) remainder case is worth it in the interest
> keeping PHP's syntax simple.
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()?
> 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)
Isn't that the division operator? ;)
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.
--
Andrea Faulds
http://ajf.me/