Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103638 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74810 invoked from network); 26 Dec 2018 19:16:50 -0000 Received: from unknown (HELO mout.gmx.net) (212.227.15.18) by pb1.pair.com with SMTP; 26 Dec 2018 19:16:50 -0000 Received: from [192.168.2.103] ([91.8.175.134]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MYg42-1gosja1ZnG-00VQmY for ; Wed, 26 Dec 2018 16:47:44 +0100 To: internals@lists.php.net Message-ID: Date: Wed, 26 Dec 2018 16:47:45 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:bVHZXCV+q0fy9MY+cs0ygC9dEA1EO1GUtRYcPBi57d2hRsBOUyT /1Hppvz4icZ3fS9sdRJes0/al8pLfQDbUL2o/+qMzYfGKzAbO9GLUcVbh4n1qOQMjXCpJIq z0y9/8DvdAvo/3KESNIfOsUOzM+439rQMAmlcxbgdfMDyZrHWfxkgHiEx+9MM0OeC+h+b82 O2aberKK/wJOTEs54EMEA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:VsZyut1kFH0=:JSw02VRFmJst4nJSZ17cR4 LRB066r/DJ6VCdICCt8MiGQhyO9EZ5FTy/csjkl6qL42hGj7Yc264ySHgzhoOKIIVVg04nQu4 llsX/WDNWJNEOrDe8nSP9MlmpppM6qggMw2Wmku9BTlq4OdqUkuP22bh3Xc68aF1QTW0Xatoo esHFu2qAYt4Zsu8anPIB0zNK6WZXPkjnNoHJ1YM+PwhUx5BEf7rLBA1RLzV9c/AApH1R4TNnZ G3ZUBTOSxEXfkgxRHKJ3vG4M5ykAe34QlbC4ZialtBtkg8/HVwKlGjAmwt2grsbl6vd6AkR24 76FtILSrRR7XB8Hd+cXNT/nQtgFZex98Z9EGWMhnTXAX3c5d9c+h4cgae6kLs4JBUG5VZK8xe +BDXBZVjs0kSKe98EBj3PoPrCLXyDVVg3RlfJUclsEMlUsbarxiB5BMWFNheG4KBnJOtZ2w+Y Hu3jSuzl5SvLkxnfetq9cADqlTxxpX54WGp/mTTfVSyBoipjsYRZ1uPxzll2fwdjtP5SBcM+c vOrBrHP74edPEV5uPdxdB8nLZQ9NIxJTB75sWKp0mfeYjh3Uf12H1yOf6EyB89VCfF+oIsamN Gzx6ta4EzMwl9cDU+CCI0na/9NqfXpBDFdb1jX6w6AWjwVFyIxd/rvvyH72ONkeCDueN9huuL 1VanO7P0NjigUfAKBZVCJ4JJGQdztLkHHfJIARTEuY5fMoemxg/wTkwrlRrFein65+TEJhppW SxD8vr9HVkwFamfNZHS5evU8mHScX4+DUIw/IAx0z645vLHJnnfUsQesMzGWLqtDW0jfl3VVt ktKjOXxRY1xSYtjPnLInmXx9SA04OE6bjZIrIQWZTthbadvqLudLpxV3T6wZy/4R26BDd0/dG UWlS7Mbw+HVXHJwPks5UB0NQ96rY8cRXV7jaOereX2iwFSV+3zhKiBI2S9D1Yj Subject: Inconsistent float to string vs. string to float casting From: cmbecker69@gmx.de ("Christoph M. Becker") 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? -- Christoph M. Becker