Skip to content

Commit fe2f216

Browse files
committed
pkg/math: reuse Ln2 and Ln10 in Log2E and Log10E
Upstream Go's math package has always used these simple divisions, and now that pkg/gen.go can resolve complex expressions via go/types, we can use exactly the same expression in our package. This change is a no-op, which is guaranteed by Example_constants. The new code is a lot less verbose and easier to understand, too. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I93dbeb26d3b496c724d53c95afad01f8583e56e0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/557323 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
1 parent 2091170 commit fe2f216

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/math/math.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ const (
151151
SqrtPhi = 1.27201964951406896425242246173749149171560804184009624861664038 // https://oeis.org/A139339
152152

153153
Ln2 = 0.693147180559945309417232121458176568075500134360255254120680009 // https://oeis.org/A002162
154-
Log2E = 1000000000000000000000000000000000000000000000000000000000000000.0 / 693147180559945309417232121458176568075500134360255254120680009
154+
Log2E = 1 / Ln2
155155
Ln10 = 2.30258509299404568401799145468436420760110148862877297603332790 // https://oeis.org/A002392
156-
Log10E = 10000000000000000000000000000000000000000000000000000000000000.0 / 23025850929940456840179914546843642076011014886287729760333279
156+
Log10E = 1 / Ln10
157157
)
158158

159159
// Copysign returns a value with the magnitude

0 commit comments

Comments
 (0)