-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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.ParseFloat issue with darwin/arm64 #48145
Comments
I believe this is |
@randall77 I don't think that resolves my issue:
If you take a look a this code, you will see that both values are the same and give
On Linux the results are consistent. Magic? Either way, one would expect a consistent behavior on all platforms |
This is evaluated at compile time, so FMA is not used. This program demonstrates the difference (without needing to invoke
It will print 0 on amd64, but that small number you've seen on arm64.
That is not the semantics of Go, unfortunately. Floating point results do vary by platform, and are allowed to by the spec. |
Thanks! |
This was exposed while testing CockroachDB. Following tests from pkg/sql/opt/exec/execbuilder fail due to floating point precision differences caused by FMA: - TestExecBuild/local/geospatial - TestExecBuild/local-vec-off/geospatial - TestExecBuild/local-spec-planning/geospatial - TestExecBuild/fakedist/geospatial - TestExecBuild/fakedist-vec-off/geospatial - TestExecBuild/fakedist-metadata/geospatial - TestExecBuild/fakedist-disk/geospatial - TestExecBuild/fakedist-spec-planning/geospatial With explicit casts in this patch, these failures are resolved. References: https://go.dev/ref/spec#Floating_point_operators golang/go#53297 golang/go#48145 disintegration/gift#20 (comment)
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
It works on Linux
https://play.golang.org/p/7qcKKj-RFd9
What did you see instead?
That's what I see on my MacBook
The text was updated successfully, but these errors were encountered: