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

strconv: FormatFloat wrong rounding #65334

Closed
vendelin8 opened this issue Jan 28, 2024 · 1 comment
Closed

strconv: FormatFloat wrong rounding #65334

vendelin8 opened this issue Jan 28, 2024 · 1 comment

Comments

@vendelin8
Copy link

vendelin8 commented Jan 28, 2024

Go version

go version go1.21.6 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/panda/.cache/go-build'
GOENV='/home/panda/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/panda/og/pkg/mod'
GOOS='linux'
GOPATH='/home/panda/og'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD=''
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3295958002=/tmp/go-build -gno-record-gcc-switches'

What did you do?

https://go.dev/play/p/RyJdylUB8cm

What did you see happen?

the result is 3.50

What did you expect to see?

the result should be 3.51 based on math rounding rules

@dominikh
Copy link
Member

3.505 cannot be represented exactly in a binary floating point number. The actual value is 3.50499999999999989341858963598497211933135986328125.

@dominikh dominikh closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 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