Skip to content

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

@Defined2014

Description

@Defined2014

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions