[php-src] PR #25873: Zend: Update dtoa.c to the latest version

From: Date: Sat, 28 Nov 2026 14:23:15 +0000
Subject: [php-src] PR #25873: Zend: Update dtoa.c to the latest version
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41156@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25873 Author: adapik This PR updates David M. Gay's dtoa.c, which we vendor in Zend/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](https://netlib.org/fp/dtoa.c), 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 gives 3.7E+5 instead of 3.70E+5. The same applies to precision, and to var_export(), json_encode() and serialize() when serialize_precision is not -1. Two of our local changes are not needed anymore: * the fix for signed overflow while reading the exponent ([b8cba88904a](https://github.com/php/php-src/commit/b8cba88904a509abd2c141ebcdb952cfd9471063)), because upstream fixed it (2023-12-09); * the explicit initialization of variables in zend_dtoa() added to silence uninitialized variable warnings ([feba2edba2e](https://github.com/php/php-src/commit/feba2edba2e0925bd3ada626beedeed229ebc6c9), [e1ab6862281](https://github.com/php/php-src/commit/e1ab68622815050dfb6ed3f927c438906c2569b9)). Upstream now initializes ilim and spec_case itself, and GCC 13 does not warn about j1 in 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** | function \ significant digits | 1 | 3 | 6 | 9 | 12 | 15 | 17 | |---|---:|---:|---:|---:|---:|---:|---:| | json_encode() | -34% | -55% | -69% | -74% | -77% | -79% | -79% | | serialize() | -22% | -49% | -67% | -74% | -76% | -78% | -78% | | var_export() | -15% | -35% | -57% | -67% | -70% | -73% | -74% | | (string) $f | -3% | -45% | -43% | -43% | -43% | -50% | -49% | | sprintf('%g') | -8% | -27% | -23% | -25% | -26% | -25% | -28% | | sprintf('%.2f') | 0% | -20% | -17% | -21% | -20% | -19% | -22% | | sprintf('%.10f') | +3% | -25% | -32% | -42% | -42% | -43% | -45% | | number_format($f, 2) | -2% | -19% | -14% | -15% | -15% | -15% | -17% | **String to float** | function \ significant digits | 1 | 3 | 6 | 9 | 12 | 15 | 17 | |---|---:|---:|---:|---:|---:|---:|---:| | json_decode() | 0% | -1% | -3% | -5% | -8% | -8% | -53% | | unserialize() | -2% | -3% | -6% | -6% | -7% | -7% | -53% | | (float) $s | 0% | -1% | -5% | -8% | -9% | -7% | -59% | The release zend_strtod.o text grows from 23 KB to 41 KB, mostly because of the new tables.

« previous php.git-pulls (#41156) next »