]> Cypherpunks repositories - gostls13.git/commit
strconv: clean up powers-of-10 table, tests
authorRuss Cox <rsc@golang.org>
Wed, 15 Oct 2025 03:24:19 +0000 (23:24 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 22 Oct 2025 20:50:44 +0000 (13:50 -0700)
commit1ff59f3dd3569e1225c9273fc205cb54df674bf5
treebbb7c6c8df2d9da50a1b90d902f88567985968bc
parent7c9fa4d5e9b65be396d7794f645b1f409a9bc39f
strconv: clean up powers-of-10 table, tests

Both Eisel-Lemire and Ryu depend on a table of
truncated 128-bit mantissas of powers of 10,
and so will Dragonbox.

This CL:
 - Moves the table to a separate file, so it doesn't look tied to Eisel-Lemire.
 - Introduces a uint128 type in math.go for the table values,
   since .Hi and .Lo are clearer than [1] and [0].
 - Generates the table from a standalone generator pow10gen.go.
 - Adds a new pow10 function in math.go to handle table access details.
 - Factors a 64x128->192-bit multiply into umul192 in math.go.
 - Moves multiplication by log₁₀ 2 and log₂ 10 into math.go.
 - Introduces an import_test.go to avoid having to type differently
   cased names in test code versus regular code.
 - Introduces named constants for the floating-point size parameters.
   Previously these were only in the floatInfo global variables.
 - Changes the BenchmarkAppendUintVarlen subtest names
   to be more useful.

Change-Id: I9826ee5f41c5c19be3b6a7c3c5f277ec6c23b39a
Reviewed-on: https://go-review.googlesource.com/c/go/+/712661
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
14 files changed:
src/strconv/atof.go
src/strconv/atoi_test.go
src/strconv/eisel_lemire.go
src/strconv/export_test.go
src/strconv/ftoa.go
src/strconv/ftoaryu.go
src/strconv/ftoaryu_test.go [deleted file]
src/strconv/import_test.go [new file with mode: 0644]
src/strconv/internal_test.go [deleted file]
src/strconv/itoa_test.go
src/strconv/math.go [new file with mode: 0644]
src/strconv/math_test.go [new file with mode: 0644]
src/strconv/pow10gen.go [new file with mode: 0644]
src/strconv/pow10tab.go [new file with mode: 0644]