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

Open
wants to merge 1 commit into
base: master
from

Conversation

6 participants
@sam002
Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

carusogabriel commented Aug 23, 2018

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

@sam002

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

sam002 commented Sep 11, 2018

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

@carusogabriel

This comment has been minimized.

Copy link
Contributor

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.

@Ocramius
Copy link
Contributor

Ocramius left a comment

Requires integration test additions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment