Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #66866: output for float as is. Same result for serialize and output float. #3460

Closed
wants to merge 1 commit into from

Conversation

@sam002
Copy link
Contributor

@sam002 sam002 commented Aug 23, 2018

'serialize_precision' was made as '-1' at 7.1.0. Also need for 'precision'.
This will simplify the debugging and will not mislead junior developers.

@sam002
Copy link
Contributor Author

@sam002 sam002 commented Aug 23, 2018

Same results need for serialize and output float numbers:

$k=0.1+0.7;
var_dump($k); //is float(0.8), but expected float(0.7999999999999999)

$res = (string)$k - json_encode($k);
print($res); //expected 0, but by default is 1.1102230246252E-16

Related issues (checked manually):
https://bugs.php.net/bug.php?id=66866
https://bugs.php.net/bug.php?id=66959
https://bugs.php.net/bug.php?id=68551
https://bugs.php.net/bug.php?id=73358

@carusogabriel
Copy link
Member

@carusogabriel carusogabriel commented Aug 23, 2018

@sam002 Looks like there was an RFC for this topic: https://wiki.php.net/rfc/precise_float_value

@sam002
Copy link
Contributor Author

@sam002 sam002 commented Aug 23, 2018

@carusogabriel Interesting, you propose create RFC for it? Why not modified for both variables at once?
This seriously confuses. Many developers expect the output of "raw" data. I linked several bugs in which people trusted output of 'var_dump' and 'echo'.
If necessary, then I will review the tests and update the variables to the actual values.

@nikic
Copy link
Member

@nikic nikic commented Aug 23, 2018

@sam002 This will definitely need at least a discussion on the internals list (which is unfortunately down at the moment...) The two ini settings are intentionally separate, in that serialization generally needs to preserve the exact value, while for many display purposes a full precision output may be counterproductive.

The middle ground here might be to make var_dump() use serialize_precision without touching echo. After all it is debugging functionality, so it should be precise.

@sam002
Copy link
Contributor Author

@sam002 sam002 commented Sep 11, 2018

@nikic What will need do? May be, propose RFC with some variants of changes?

@carusogabriel
Copy link
Member

@carusogabriel carusogabriel commented Sep 11, 2018

This will definitely need at least a discussion on the internals list

@sam002 Means you should email internals@php.net to start a discussion about this.

Copy link
Contributor

@Ocramius Ocramius left a comment

Requires integration test additions.

@krakjoe
Copy link
Member

@krakjoe krakjoe commented Oct 3, 2019

Since there has been no movement on this in more than a year, no discussion was started and the patch is incomplete, I'm closing this.

If there is to be further work on this issue please reference this PR from the new request (and or RFC).

@krakjoe krakjoe closed this Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants