Re: [RFC] [DISCUSSION] Locale-independent float to string cast

From: Date: Tue, 24 Mar 2020 10:53:11 +0000
Subject: Re: [RFC] [DISCUSSION] Locale-independent float to string cast
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-109267@lists.php.net to get a copy of this message
On 24.03.2020 at 11:03, Lynn wrote: >> Outputting floats as strings in locales which change the decimal >> separator will have a slightly different output. In our opinion, the >> backward compatibility break won't be serious in practice > > In my opinion, this will be huge. I can't trace back where the thousands of > possible conversions are used in legacy software. There's a variety of > custom format functions, sprintf implementations, string casts, and > number_format usages. Would it be possible to trigger a warning or > deprecation when using a locale that would have a different result from > what the new result will be? If I'd use a locale that results in > 3.5, I > don't need a warning. If I use a locale that results in > 3,5, I would like > to see a warning of sorts so I can fix this before untested legacy code > will seriously break data exports. It would certainly be *possible* to raise a warning/notice if a (non SCCP optimized) float to string conversion would have different results. This would have a (small) performance impact though, so I'd would rather avoid enforcing it (i.e. maybe temporarily introduce an INI directive for this purpose). -- Christoph M. Becker

« previous php.internals (#109267) next »