Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-26 Thread Saki Takamachi
Hi Marco, Benjamin, > As for tuple vs reference, I think the general direction is to move away from > references as much as possible, and AFAIK references actually make things > harder for IDEs and static analysis tools, whereas the tuple syntax > array{string, string} is well understood at lea

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Marco Pivetta
Hey Benjamin, On Tue, 25 Jun 2024 at 22:24, Benjamin Morel wrote: > > I predicted this would probably be on the agenda. Another idea is to pass >> arguments by reference, like in `exec()`. >> >> Personally, I find something like a tuple easier to use. However, without >> generics, all we know is

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Benjamin Morel
> > I see, I understand. > > But I don't think that's wise. For example, if we reversed the order of > the div and mod, there would be no cache and we wouldn't get the speed > boost. (Or does it cache the quotient as well?) > I don't think the cache is a good idea either, for the reasons you menti

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Saki Takamachi
Hi Barney, > If anything I was thinking of recording the remainder in the the original > number object, not the one returned (or possibly in something like a WeakMap > keyed to it). So it does increase state and makes it technically no longer > immutable, but that change in state would not be d

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Barney Laurance
On Tue, 25 Jun 2024 17:29:58 +0100 Saki Takamachi wrote --- > > Also, it is not practical to record the remainder in the Number object > resulting from the division. This is because there can be objects whose > division results are equal but whose remainders are different. >

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Saki Takamachi
Thanks all, > 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, j

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Barney Laurance
On Tue, 25 Jun 2024 10:11:10 +0100 Saki Takamachi wrote --- > Hi internals, > > 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

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Benjamin Morel
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

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Larry Garfield
On Tue, Jun 25, 2024, at 9:11 AM, Saki Takamachi wrote: > Hi internals, > > 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 dem

Re: [PHP-DEV] Add bcdivmod() to BCMath

2024-06-25 Thread Morgan
On 2024-06-25 21:11, Saki Takamachi wrote: Hi internals, 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?