Re: Change default serialize precision from 100 to 17

From: Date: Wed, 09 Feb 2011 04:07:37 +0000
Subject: Re: Change default serialize precision from 100 to 17
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-51439@lists.php.net to get a copy of this message
Yes, I think it's dangerous to change the default display precision lest we have a ton of applications that currently show 0.2 showing 0.20000000000000001.
Exactly. And remember, PHP output is not necessarily just for web pages for humans to read. Other apps may rely on parsing this data, etc., and may break if precision changes unexpectedly.
Would it be possible to "displays a value based on the shortest decimal fraction that rounds correctly back to the true binary value", like python 2.7 and 3.1 do ? (http://docs.python.org/tutorial/floatingpoint.html)
This may be a good idea for trunk, but I don't think it's feasible for 5.3 for the same reason.
Announced as part of a major or point upgrade, I guess this would be OK. But it still doesn't solve the core problem, which is that the display precision is being used where it shouldn't be used, e.g. for DB communications.
Showing "shortest decimal fraction that rounds correctly back to the true binary value" works fine for numbers that are directly input, where the only error is the normal rounding error (i.e., total uncertainty for x is x*2^-53). Once you start making calculations with the numbers the errors start being propagated, so in these scenarios you would still end up with a lot more "ugly" string representations that you have today with the default display precision.
Yeah. For this reason, I think it would be more of a nuisance for the average app than a help. A lower display precision is actually desirable.
I agree that the information loss in e.g. PDO must be fixed, but it seems more appropriate to fix those problems by forcing another precision only in those cases.
A much better way to fix it. Ben.

« previous php.internals (#51439) next »