-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed as not planned
Labels
Description
Go version
1.21
What operating system and processor architecture are you using (go env)?
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/seba/dev/logiccloud/rounding-test/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'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/65/jfg8j9sn7jdftxk_ny295yvh0000gn/T/go-build2794130776=/tmp/go-build -gno-record-gcc-switches -fno-common'What did you do?
Converting a float32 to an integer type has different behaviors on darwin/arm64 vs x86 when the float value overflows the target integer type. A sample project can be found here: https://go.dev/play/p/WZoGD3q1LBx
What did you expect to see?
darwin/arm64
| float64 | int8 | uint8 | uint64 |
|---|---|---|---|
| 3.4028234663852886e+38 | -1 | 255 | 18446744073709551615 |
| -3.4028234663852886e+38 | 0 | 0 | 0 |
| 256 | 0 | 0 | 256 |
| -1.4 | -1 | 255 | 0 |
What did you see instead?
linux/x86
| float64 | int8 | uint8 | uint64 |
|---|---|---|---|
| 3.4028234663852886e+38 | 0 | 0 | 9223372036854775808 |
| -3.4028234663852886e+38 | 0 | 0 | 9223372036854775808 |
| 256 | 0 | 0 | 256 |
| -1.4 | -1 | 255 | 18446744073709551615 |