this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pkg/math: fix Log2E and Log10E constant expressions

They were a division of integer constants, which got truncated,
meaning that Log2E rounded down to 1 and Log10E to 0.

To force them to be floating-point constants, like the CUE ones,
turn the dividend into a floating-point constant.

I found this problem since staticcheck correctly pointed out
a constant integer division which resulted in zero:

math.go:156:11: the integer division '100… / 230…' results in zero (SA4025)

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I36ee54a7c8aff06368016b855536a9614dbbf229
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/557322
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.io>

+4 -4
+2 -2
pkg/math/math.go
··· 151 151 SqrtPhi = 1.27201964951406896425242246173749149171560804184009624861664038 // https://oeis.org/A139339 152 152 153 153 Ln2 = 0.693147180559945309417232121458176568075500134360255254120680009 // https://oeis.org/A002162 154 - Log2E = 1000000000000000000000000000000000000000000000000000000000000000 / 693147180559945309417232121458176568075500134360255254120680009 154 + Log2E = 1000000000000000000000000000000000000000000000000000000000000000.0 / 693147180559945309417232121458176568075500134360255254120680009 155 155 Ln10 = 2.30258509299404568401799145468436420760110148862877297603332790 // https://oeis.org/A002392 156 - Log10E = 10000000000000000000000000000000000000000000000000000000000000 / 23025850929940456840179914546843642076011014886287729760333279 156 + Log10E = 10000000000000000000000000000000000000000000000000000000000000.0 / 23025850929940456840179914546843642076011014886287729760333279 157 157 ) 158 158 159 159 // Copysign returns a value with the magnitude
+2 -2
pkg/math/math_test.go
··· 54 54 // SqrtPi: 1.772453850905516 55 55 // SqrtPhi: 1.272019649514069 56 56 // Ln2: 0.6931471805599453 57 - // Log2E: 1 57 + // Log2E: 1.4426950408889634 58 58 // Ln10: 2.302585092994046 59 - // Log10E: 0 59 + // Log10E: 0.4342944819032518 60 60 }