From dc8fb1302144cb255974d7724d65a9b1c869d78b Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 24 Mar 2020 11:06:26 +0300 Subject: [PATCH] vm: make NewBigInteger accept int64 It is more correct upconvert to int64 if needed, so precision is never lost. --- pkg/vm/cli/cli.go | 2 +- pkg/vm/stack_item.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/vm/cli/cli.go b/pkg/vm/cli/cli.go index 0eec6dbff..2cef728fe 100644 --- a/pkg/vm/cli/cli.go +++ b/pkg/vm/cli/cli.go @@ -434,7 +434,7 @@ func parseArgs(args []string) ([]vm.StackItem, error) { return nil, errors.New("failed to parse bool parameter") } case intType: - val, err := strconv.Atoi(value) + val, err := strconv.ParseInt(value, 10, 64) if err != nil { return nil, err } diff --git a/pkg/vm/stack_item.go b/pkg/vm/stack_item.go index 71529f9f9..d4e71756a 100644 --- a/pkg/vm/stack_item.go +++ b/pkg/vm/stack_item.go @@ -191,9 +191,9 @@ type BigIntegerItem struct { } // NewBigIntegerItem returns an new BigIntegerItem object. -func NewBigIntegerItem(value int) *BigIntegerItem { +func NewBigIntegerItem(value int64) *BigIntegerItem { return &BigIntegerItem{ - value: big.NewInt(int64(value)), + value: big.NewInt(value), } }