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