Repository navigation
Conversation
887f482 to
bd8085a
Compare
|
I think that s the right route, might be good to write as comment the changelog version related to this somewhere. |
9f3c94c to
55d8c84
Compare
|
@devnexen I agree, it's a good idea, thanks. I added a note to the header of /* Synchronized with netlib dtoa.c as of the 20260911 entry of
* https://www.netlib.org/fp/changes
*/ |
55d8c84 to
d1ad01c
Compare
did you ? maybe it was swallowed during one of your edits. |
|
@devnexen yes, it's here, right after the Gay's license https://github.com/php/php-src/pull/25873/changes#diff-00c021f0e6e6c4fdc1e8daef206a0ff07e9ac0f1a579e27b78750a094788fc9bR23 |
|
my bad yes you re right :) |
|
I have scheduled a real-time benchmark for you. Just to make sure no unintented regressions. Good to go if the results are all positive. |
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.