Re: [RFC] [Discussion] Support object type in BCMath
| From: | Larry Garfield | Date: | Tue, 26 Mar 2024 14:40:04 +0000 |
| Subject: | Re: [RFC] [Discussion] Support object type in BCMath | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122754@lists.php.net to get a copy of this message | ||
On Tue, Mar 26, 2024, at 12:50 PM, Saki Takamachi wrote:
> Hi Barney,
>
>> No, that's not quite what I meant - I meant more like the opposite:
>>
>>
>> ```
>> $bcNum = new BcNum('1234567890123456789.23456789');
>> echo $bcNum->format(8, '.', ',') //
>> 1,234,567,890,123,456,789.23456789
>> ```
>>
>>
>> Maybe also worth providing a way to specify that all decimals should be printed, instead of
>> just a fixed number of decimals.
>
> Ah I see! It sounds exactly like
number_format. Sure, this
> might make
> sense. To me, this seems worth supporting.
>
>
> BTW,
> ```
> $bcNum = new BcNum('1234567890123456789.23456789’);
> ```
>
> When I saw this, I thought that the behavior when $scale is omitted is
> that in addition to the option of "using the global setting value",
> there is also the option of "counting the length of $num
> and storing
> all $num”. In other words, it does not use any global
> settings.
>
> Which of these do you think is better?
Global mode settings are an anti-pattern in most cases. Please avoid those whenever possible, as
they lead to unpredictable behavior.
--Larry Garfield