On 04/03/2021 13:17, Nikita Popov wrote:
A disadvantage of narrowing the definition in such a fashion is that it introduces a discrepancy with (float) casts. I believe these currently recognize the same values, with the exception that (float) discards trailing garbage.
I don't think that's a big problem; as you say, explicit casts are already more lax than implicit ones, and that's always going to be the case in some sense, because they never "fail". Opinions may vary, though.
Another disadvantage is that exponential notation is commonly returned for large numbers by various data source -- e.g. if you stored a large float in a database, I'd expect you'd get it back in exponential notation (if you get it back as a string). This means that your code could suddenly break because the range of a value passes some heuristic threshold for how it gets printed.
That may be a more compelling reason, at least given backwards compatibility requirements. I don't know how common that is, but it certainly sounds plausible.
Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php