On Thursday 03 August 2023 21:07:57 (+02:00), Ben Ramsey wrote:

>
> > The default rounding mode in ICU for the number formatter appears to be > "half even," and that's probably why it's the default in PHP. > > See: > > - > https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes#half-even


> - > https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1number_1_1NumberFormatterSettings.html#aceb7d34843e0d44e138fb3f43c98db32


> The MDN documentation you linked to describes the JavaScript > implementation of ECMA-402, which differs from ICU in a number of ways. > One of which is in the default rounding mode for `Intl.NumberFormat`, > which is not the same as ICU's `NumberFormatter` (even though most > ECMA-402 implementations use icu4c internally). > > Here's where ECMA-402 defines `halfExpand` as the default for > `roundingMode` (see step 10 under section 15.1.3): > > https://tc39.es/ecma402/#sec-setnfdigitoptions > > Since PHP's intl extension follows icu4c and not ECMA-402, I think it > makes sense for it to continue to use the same default values as icu4c.


Thank you for this differentiation, my reference to MDN I found
interesting as they've chosen the same approach as PHP with
number_format(), obviously they also choose the name of the function
because of that^^.

Jokes aside, your reference to ICU itself and PHPs connection to it
is most likely the true explanation why that is the default rounding
mode in NumberFormatter.

And honestly, from a core perspective, it would likely be surprising
if it would be otherwise then (the change asked about).

I'm not the person to draw this line, but in hindsight of output
formatting - obviously the totally other side - the current default is
surprising, too.

But it is certainly the safer path to not change it.


For now, I've already learned a lot more and should take some time to
look into this. E.g. understanding why this is the default in ICU,
perhaps there is some more valuable information.

Thanks & Best,

-- hakre

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to