Den ons. 26. dec. 2018 kl. 16.53 skrev Nikita Popov <nikita....@gmail.com>:
>
> On Wed, Dec 26, 2018 at 4:48 PM Christoph M. Becker <cmbecke...@gmx.de>
> wrote:
>
> > Hi!
> >
> > Regarding the decimal separator (aka. decimal point), the behavior of
> > casting float to string is inconsistent with casting string to float.
> > While the former regards the current locale, the latter always expects a
> > decimal point regardless of the locale.  This breaks round-trips for
> > locales which use something else than a dot as decimal separator (e.g.
> > German, which uses a comma), for instance:
> >
> >     $float = 1/3;              // float(0,33333333333333)
> >     $string = (string) $float; // string(16) "0,33333333333333"
> >     $float = (float) $string;  // float(0)
> >
> > As for me, the question is not *if*, but rather *when* and *how* this
> > inconsistency should be resolved.  Regarding the *when*, it seems to me
> > we have to wait for the next major version, i.e. PHP 8.  Regarding the
> > *how* I tend to prefer the non-locale aware behavior, i.e. float to
> > string conversion should always produce a decimal *point*.  Users still
> > can explicitly use number_format() or NumberFormatter if they wish.
> >
> > Thoughts?
> >
>
> Yes, please. Locale-sensitive library functions are bad enough, but core
> language behavior should *never* be locale-sensitive.
>
> I'm definitely in favor of making float to string casts locale-independent
> in PHP 8.

I'm in the same boat here. I remember we had some interesting
behaviorial differences on a language level too[1] (which seems to
also have maybe resurfaced after reading the newest comments).

[1] https://bugs.php.net/bug.php?id=18556



-- 
regards,

Kalle Sommer Nielsen
ka...@php.net

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

Reply via email to