Files
Raúl MarínandClaude Opus 4.6 b7752dd78d Extend itoa fast path to Float64 exp 54-62 with rounding
Same approach as the Float32 rounding: for Float64 values with
normalizedExponent 54-62 (roughly 1.8e16 to 9.2e18), find the "roundest"
integer within the valid dragonbox range using compile-time constant
modulo operations (% 10, % 100, % 1000, % 10000).

Also adds exp=53 (ULP=2) to the plain itoa path, same as Float32 exp=24.

Verified: exhaustive check of all 2.1B positive Float32 values, plus
1 billion random Float64 samples (100M per exponent) and all power-of-2
boundary values — zero mismatches with dragonbox.

Add a performance test for Float64 large integers starting at 2^53.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-03-25 01:09:05 +01:00

57 lines
2.5 KiB
XML

<!--
The tests times are wildly different, e.g. toString(number % 100)
is 10 times faster than toString(number % 100 + 0.5). The shorter
queries are somewhat unstable, so ignore differences less than 10%.
-->
<test>
<substitutions>
<substitution>
<name>expr</name>
<values>
<value>toFloat64(number)</value>
<value>toFloat64(number % 2)</value>
<value>toFloat64(number % 10)</value>
<value>toFloat64(number % 100)</value>
<value>toFloat64(number % 1000)</value>
<value>toFloat64(number % 10000)</value>
<value>toFloat64(number % 100 + 0.5)</value>
<value>toFloat64(number % 100 + 0.123)</value>
<value>toFloat64(number % 1000 + 0.123456)</value>
<value>number / 2</value>
<value>number / 3</value>
<value>number / 7</value>
<value>number / 16</value>
<value>toFloat32(number)</value>
<value>toFloat32(number % 2)</value>
<value>toFloat32(number % 10)</value>
<value>toFloat32(number % 100)</value>
<value>toFloat32(number % 1000)</value>
<value>toFloat32(number % 10000)</value>
<value>toFloat32(number % 100 + 0.5)</value>
<value>toFloat32(number % 100 + 0.123)</value>
<value>toFloat32(number % 1000 + 0.123456)</value>
</values>
</substitution>
<substitution>
<name>expr_zero</name>
<values>
<value>1 / rand()</value>
<value>rand() / 0xFFFFFFFF</value>
<value>0xFFFFFFFF / rand()</value>
<value>toFloat64(rand())</value>
<value>toFloat64(rand64())</value>
<value>toFloat32(rand())</value>
<value>toFloat32(rand64())</value>
<value>reinterpretAsFloat32(reinterpretAsString(rand()))</value>
<value>reinterpretAsFloat64(reinterpretAsString(rand64()))</value>
</values>
</substitution>
</substitutions>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(toString({expr}))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(toString({expr_zero}))</query>
<!-- Float64 large integers (exp 53+): tests the extended itoa fast path with rounding -->
<query>SELECT count() FROM numbers(9007199254740992, 10000000) WHERE NOT ignore(toString(toFloat64(number)))</query>
</test>