]> Cypherpunks repositories - gostls13.git/commit
strconv: make Eisel-Lemire handle long mantissas
authorRémy Oudompheng <remyoudompheng@gmail.com>
Fri, 23 Oct 2020 20:23:21 +0000 (22:23 +0200)
committerNigel Tao <nigeltao@golang.org>
Thu, 29 Oct 2020 22:44:49 +0000 (22:44 +0000)
commitf43e012084c4edd381d21c9988638535696775ea
tree4effd5ebea8e32e27155e84a65d3f3c1e834bc62
parent75789880a6693a4a0645f1b5924d1ede87308a63
strconv: make Eisel-Lemire handle long mantissas

In many cases, it is not necessary to parse long
decimal mantissas entirely to produce the correctly
rounded floating-point number. It is enough to parse
the short, rounded lower and upper bounds and in most cases
they round to the same floating point number because uint64
can hold 19 digits.

Previously this case was handled by the extFloat code path
(Grisu3 algorithm).

name                      old time/op  new time/op  delta
Atof64Big-4               1.07µs ± 2%  0.11µs ± 2%  -89.61%  (p=0.000 n=10+9)
Atof64RandomLongFloats-4  8.03µs ± 2%  0.14µs ± 7%  -98.24%  (p=0.000 n=10+10)
Atof32RandomLong-4         760ns ± 1%   156ns ± 0%  -79.46%  (p=0.000 n=10+8)

Benchmarks versus extFloat:

name                      old time/op  new time/op  delta
Atof64Big-4                121ns ± 3%   111ns ± 2%   -7.93%  (p=0.000 n=10+9)
Atof64RandomLongFloats-4   144ns ± 1%   142ns ± 7%     ~     (p=0.167 n=10+10)
Atof32RandomLong-4         129ns ± 1%   156ns ± 0%  +21.12%  (p=0.000 n=10+8)

Change-Id: Id734b8c11e74b49a444fda67ee72870ae9422e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/264677
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
src/strconv/atof.go
src/strconv/atof_test.go