Re: [RFC] [Discussion] Support object type in BCMath
| From: | Barney Laurance | Date: | Tue, 26 Mar 2024 12:07:51 +0000 |
| Subject: | Re: [RFC] [Discussion] Support object type in BCMath | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122747@lists.php.net to get a copy of this message | ||
On 2024-03-26 11:35, Saki Takamachi wrote:
**I immediately reflected the above two points in my RFC** :DThanks, looks good.
No, that's not quite what I meant - I meant more like the opposite:One more suggestion - might it be worth adding aI came up with the following code, is it close to what you intended?formatfunction to the new BcNum class? This would be similar to the existing number_format function, but would avoid the need to lose precision by converting to float first.$num = BcNum::fromNumberFormat(1.2345, 5); $num->value; // 1.23450
$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.