Hi,

I've been working on improving performance of BCMath lately, and I found
> that I can get the div and mod in one calculation. This is obviously faster
> than calculating it twice separately.
>
> Do you think there's a demand for this feature?
>
> e.g.
> ```
> [$quot, $rem] = bcdivmod('123', '2');
> // $quot is '61', $rem is '1'
> ```
>
> The naming and return value scheme is inspired by Python and Ruby.
>
> Of course, if this is added, equivalent functionality will be added to the
> Number class.
>
> Regards,
>
> Saki
>

I would definitely use this in brick/math:

https://github.com/brick/math/blob/0.12.1/src/Internal/Calculator/BcMathCalculator.php#L43-L49


> This isn't something I'm likely to ever use as I don't do complex math
> much, but it seems like a reasonable optimization for those that do.  No
> objection.
>
> My only question is the pseudo-tuple return, which is rarely used in PHP
> (although I've used it myself, I think exactly once), and I think this
> would be the first use of it in a built in library.  (I may be wrong on
> that.)  I don't have a particular alternative to suggest, just flagging
> that as the main part that could warrant discussion.
>
> --Larry Garfield
>

It's actually already used by gmp_div_qr(), so +1 from me.

- Benjamin

Reply via email to