Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math: tan(math.Pi / 4) returns different values on amd64 vs arm64 #65337

Closed
Defined2014 opened this issue Jan 29, 2024 · 2 comments
Closed

math: tan(math.Pi / 4) returns different values on amd64 vs arm64 #65337

Defined2014 opened this issue Jan 29, 2024 · 2 comments

Comments

@Defined2014
Copy link

Go version

go version go1.21.5 darwin/arm64 and linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/jasonmo/Library/Caches/go-build'
GOENV='/Users/jasonmo/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/jasonmo/go/pkg/mod'
GONOPROXY='github.com/pingcap/*'
GONOSUMDB='github.com/pingcap/*'
GOOS='darwin'
GOPATH='/Users/jasonmo/go'
GOPRIVATE='github.com/pingcap/*'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/jasonmo/github/tidb-x/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'

What did you do?

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"
	"math"
)

func main() {
	b := math.Tan(math.Pi / 4)
	fmt.Println(b)
}

What did you see happen?

On Arm64 env:

0.9999999999999998

On Amd64 env:

1

What did you expect to see?

Results should be same and equal to 1.

@mauri870
Copy link
Member

That is to be expected, the language spec says that the results of floating point operations is platform dependent.

The math package docs also state this at the very top.

@mauri870
Copy link
Member

Duplicate of #18354

@mauri870 mauri870 marked this as a duplicate of #18354 Jan 29, 2024
@mauri870 mauri870 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants