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: cast string "24994434550311665182" to *big.Int resolves in invalid instance #43171

Closed
sham789 opened this issue Dec 14, 2020 · 2 comments

Comments

@sham789
Copy link

sham789 commented Dec 14, 2020

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

$ go version
go version go1.15.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/shamil/Library/Caches/go-build"
GOENV="/Users/shamil/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=" -mod="
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/shamil/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/shamil/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/usr/local/var/www/susy-ping-pong-bot/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w5/s3w49d_j2vg9p5xjv7dl4bdh0000gn/T/go-build800082162=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://play.golang.org/p/AmEckBDqrFo

What did you expect to see?

I expect to see that "24994434550311665182" string casts to valid *big.Int.
With appropriate true results while calling .IsInt64() and .IsUint64()

What did you see instead?

Instead, I see that "24994434550311665182" cast string is invalid *big.Int instance.
When I try to retrieve .Int64() I see "6547690476602113566".

@ALTree
Copy link
Member

ALTree commented Dec 14, 2020

24994434550311665182 is both bigger that the biggest positive signed int64 and bigger than the biggest unsigned uint64 , so your expectation seems wrong.

@ALTree ALTree closed this as completed Dec 14, 2020
@sham789
Copy link
Author

sham789 commented Dec 14, 2020

Thank you

@golang golang locked and limited conversation to collaborators Dec 14, 2021
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

3 participants