Skip to content

math: Exp(x) function on amd64 can not return denormal numbers #23164

@erifan

Description

@erifan

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Go version devel +2de98eb Sat Dec 16 23:30:58 2017 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/username/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/username/golangworkspace"
GORACE=""
GOROOT="/home/username/golang"
GOTMPDIR=""
GOTOOLDIR="/home/username/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build362762432=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Add a test case: Exp(-740.0) for Exp(x) function, and verify the correctness of Exp(x) with commands:
cd golang/src/math/
../../bin/go test -c
./math.test -test.run TestExp$
Changes are as follow:

diff --git a/src/math/all_test.go b/src/math/all_test.go
index 0412c19..47cf947 100644
--- a/src/math/all_test.go
+++ b/src/math/all_test.go
@@ -1012,6 +1012,7 @@ var vfexpSC = []float64{
        1.48852223e+09,
        1.4885222e+09,
        1,
+       -7.40e+02,                           // The input parameters of Exp(x) function
 }
 var expSC = []float64{
        0,
@@ -1023,6 +1024,7 @@ var expSC = []float64{
        Inf(1),
        Inf(1),
        2.718281828459045,
+       4.2e-322,                             // The expected result of Exp(-740.0)
 }

 var vfexp2SC = []float64{

What did you expect to see?

PASS

What did you see instead?

--- FAIL: TestExp (0.00s)
all_test.go:2277: Exp(-740) = 0, want 4.2e-322
FAIL

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions