mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
30 lines
613 B
Go
30 lines
613 B
Go
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package strconv
|
|
|
|
type Uint128 = uint128
|
|
|
|
var (
|
|
BaseError = baseError
|
|
BitSizeError = bitSizeError
|
|
MulLog10_2 = mulLog10_2
|
|
MulLog2_10 = mulLog2_10
|
|
ParseFloatPrefix = parseFloatPrefix
|
|
Pow10 = pow10
|
|
Umul128 = umul128
|
|
Umul192 = umul192
|
|
)
|
|
|
|
func NewDecimal(i uint64) *decimal {
|
|
d := new(decimal)
|
|
d.Assign(i)
|
|
return d
|
|
}
|
|
|
|
func SetOptimize(b bool) bool {
|
|
old := optimize
|
|
optimize = b
|
|
return old
|
|
}
|