Repository navigation
Conversation
adapik
force-pushed
the
zend-dtoa-update
branch
from
November 28, 2026 14:43
e7a5e15 to
887f482
Compare
adapik
force-pushed
the
zend-dtoa-update
branch
from
November 28, 2026 15:16
887f482 to
bd8085a
Compare
Member
|
I think that s the right route, might be good to write as comment the changelog version related to this somewhere. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates David M. Gay's
dtoa.c, which we vendor inZend/zend_strtod.c. Our copy corresponds to the upstream version of 2013-12-09. This PR updates it to the version of 2026-09-08, the latest one available.The public interface of the functions PHP uses and the big integer algorithms are unchanged. The most noticable change is in the 2016-04-29 version, which added much faster conversion paths based on 64-bit integer arithmetic and a table of 96-bit powers of ten.
The versions since then also fix many bugs and incorrect results. A good part of those fixes are in the new code or in options PHP does not use. One of them is visible in PHP: when an exact tie is rounded down, there is no trailing zero anymore (2016-03-25), so
sprintf('%.3G', 370500.0)now gives3.7E+5instead of3.70E+5. The same applies toprecision, and tovar_export(),json_encode()andserialize()whenserialize_precisionis not -1.Two of our local changes are not needed anymore:
zend_dtoa()added to silence uninitialized variable warnings (feba2edba2e, e1ab6862281). Upstream now initializesilimandspec_caseitself, and GCC 13 does not warn aboutj1in the new code.The update makes float to string and string to float conversions significantly faster. It also closes the gap with upstream that built up over the years, which should make future updates easier.
Benchmarks:
Float to string
json_encode()serialize()var_export()(string) $fsprintf('%g')sprintf('%.2f')sprintf('%.10f')number_format($f, 2)String to float
json_decode()unserialize()(float) $sThe release
zend_strtod.otext grows from 23 KB to 41 KB, mostly because of the new tables.