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/big: Int64() conversion incorrect despite Exact accuracy #17305

Closed
johnSchnake opened this issue Oct 1, 2016 · 1 comment
Closed

math/big: Int64() conversion incorrect despite Exact accuracy #17305

johnSchnake opened this issue Oct 1, 2016 · 1 comment

Comments

@johnSchnake
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.7.1 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/johnschnake/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sw/m66hd5gs4jq4rgzr1s_hvv2c0000gn/T/go-build059909108=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
https://play.golang.org/p/iVPRHj3eZ9

What did you expect to see?

"Correct and exact" as output; implying that since math/big accuracy of Float.Int64() reported Exact, that I would get the same value as the same input cast to an int64.

What did you see instead?

"Not equal, despite exact" as output; implying that even though the same values went in as inputs, and math/big reported the conversion could occur w/o rounding, the values were not equal.

@johnSchnake
Copy link
Author

Disregard, I see now a few issues with my example. I should have used math.MinInt64 in this particular example and that the loss of precision was occurring when originally cast into the float64 prior to the big.Float.

@golang golang locked and limited conversation to collaborators Oct 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants