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

fix: upgrade apd lib to version without bug #1399

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/op_binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"math/big"

"github.com/cockroachdb/apd"
"github.com/cockroachdb/apd/v3"
)

// ----------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions gnovm/pkg/gnolang/op_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"strings"

"github.com/cockroachdb/apd"
"github.com/cockroachdb/apd/v3"
)

func (m *Machine) doOpEval() {
Expand Down Expand Up @@ -160,8 +160,7 @@ func (m *Machine) doOpEval() {
panic(fmt.Sprintf("error computing exponent: %v", err))
}
// Step 3 make Decimal from mantissa and exp.
var dValue *big.Int
dValue = new(big.Int)
dValue := new(apd.BigInt)
_, ok := dValue.SetString(hexString, 16)
if !ok {
panic(fmt.Sprintf("can't convert %s to decimal", value))
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/op_inc_dec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"math/big"

"github.com/cockroachdb/apd"
"github.com/cockroachdb/apd/v3"
)

func (m *Machine) doOpInc() {
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/op_unary.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"math/big"

"github.com/cockroachdb/apd"
"github.com/cockroachdb/apd/v3"
)

func (m *Machine) doOpUpos() {
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"unsafe"

"github.com/cockroachdb/apd"
"github.com/cockroachdb/apd/v3"

"github.com/gnolang/gno/tm2/pkg/crypto"
)
Expand Down
4 changes: 2 additions & 2 deletions gnovm/pkg/gnolang/values_conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"strconv"

"github.com/cockroachdb/apd"
"github.com/cockroachdb/apd/v3"
)

// t cannot be nil or untyped or DataByteType.
Expand Down Expand Up @@ -1113,7 +1113,7 @@ func ConvertUntypedBigintTo(dst *TypedValue, bv BigintValue, t Type) {
return // done
case BigdecKind:
dst.T = t
dst.V = BigdecValue{V: apd.NewWithBigInt(bi, 0)}
dst.V = BigdecValue{V: apd.NewWithBigInt(new(apd.BigInt).SetMathBigInt(bi), 0)}
return // done
default:
panic(fmt.Sprintf(
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/values_conversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"math"
"testing"

"github.com/cockroachdb/apd"
"github.com/cockroachdb/apd/v3"
"github.com/stretchr/testify/require"
)

Expand Down
19 changes: 19 additions & 0 deletions gnovm/tests/files/math4.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

func main() {
println(-3.0 * 1.0 / 2.0) // -1.5
println(-3.0 * 1.0 / 2) // -1.5
println(-3.0 * 1 / 2.0) // -1.5

println(-3 * 1.0 / 2.0) // 1.5
println(-3 * 1.0 / 2) // 1.5
println(-3 * 1 / 2.0) // 1.5
}

// Output:
// -1.5
// -1.5
// -1.5
// -1.5
// -1.5
// -1.5
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/cockroachdb/apd v1.1.0
github.com/cockroachdb/apd/v3 v3.2.1
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/dgraph-io/badger/v3 v3.2103.4
Expand Down Expand Up @@ -60,7 +60,6 @@ require (
github.com/gorilla/sessions v1.2.1 // indirect
github.com/klauspost/compress v1.12.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
5 changes: 2 additions & 3 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion misc/loop/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgraph-io/badger/v3 v3.2103.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions misc/loop/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading