[PHP-DEV] Re: Inconsistent float to string vs. string to float casting

2019-01-04 Thread Christoph M. Becker
On 26.12.2018 at 16:47, Christoph M. Becker wrote: > 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 o

[PHP-DEV] Re: Inconsistent float to string vs. string to float casting

2019-01-02 Thread Umberto Salsi
cmbecke...@gmx.de ("Christoph M. Becker") wrote: > [...] 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. We all agree that the basic featur

[PHP-DEV] Re: Inconsistent float to string vs. string to float casting

2018-12-27 Thread Christoph M. Becker
On 27.12.2018 at 18:57, Christoph M. Becker wrote: > […] filter_var() with > FILTER_VALIDATE_FLOAT can also be used, and might be the best option if > you don't know which decimal separator is used, and you are sure there > are no thousands separators in the string. No, that doesn't work, since t

[PHP-DEV] Re: Inconsistent float to string vs. string to float casting

2018-12-27 Thread Christoph M. Becker
On 27.12.2018 at 17:33, Umberto Salsi wrote: > cmbecke...@gmx.de ("Christoph M. Becker") wrote: > >> Regarding the decimal separator (aka. decimal point), the behavior of >> casting float to string is inconsistent with casting string to float. >> [...] > > I'm shocked... Lot of code here assumes

[PHP-DEV] Re: Inconsistent float to string vs. string to float casting

2018-12-27 Thread Umberto Salsi
cmbecke...@gmx.de ("Christoph M. Becker") wrote: > Hi! > > Regarding the decimal separator (aka. decimal point), the behavior of > casting float to string is inconsistent with casting string to float. > [...] I'm shocked... Lot of code here assumes (float) does the exact reverse of (string); foru