-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use serialize_precision for printing floats in var_dump() #5172
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
Conversation
b1193aa
to
bfb433b
Compare
bfb433b
to
dec1527
Compare
print_r() should also be modified, I think. |
Thank you so much for doing this! I had worked on a patch for this but never finished it. |
@claudepache Agreed, going to do that in a separate PR. @hikari-no-yume Doing this kind of change has gotten a lot easier, thanks to the magic of bless_tests.php. |
@claudepache @nikic Personally I think updating
|
@hikari-no-yume Yeah, just saw your mail. I agree with your assessment there, print_r should follow print semantics. To be honest, I have no idea why that function even exists, it seems like a strictly inferior version of var_dump. |
(Hope not to sidetrack things too much…) It seems like its niche is meant to be a way to “print” arrays and objects and have it be nicer for humans to read than |
var_dump() is debugging functionality, so it should print floating-point numbers accurately. We do this by switching to
serialize_precision
, which (by default) will print with as much precision as necessary to preserve the exact value of the float.