Skip to content

Commit

Permalink
fix a bigint issue
Browse files Browse the repository at this point in the history
Signed-off-by: Toby Yan <me@tobyan.com>
  • Loading branch information
toby1991 committed May 13, 2019
1 parent 22dd338 commit 12e9dbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion model/types/bigfloat/bigfloat_test.go
Expand Up @@ -6,6 +6,8 @@ import (
"math/big"
"strings"
"testing"

"github.com/totoval/framework/model/types/bigint"
)

type testAdd struct {
Expand Down Expand Up @@ -159,8 +161,14 @@ func TestBigFloat_Convert(t *testing.T) {
log.Println(a.Prec())
log.Println(a.Text('f', 1024))
b := BigFloat{}
b.CreateFromString(a.Text('f', 1024), ToNearestEven)
b.Convert(a)
fmt.Println(b.String())

c := big.Int{}
c.SetString("312343532485823940580923458934", 10)
d := bigint.BigInt{}
d.Convert(&c)
fmt.Println(d.String())
}

func TestBigFloat_Floor(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion model/types/bigint/bigint.go
Expand Up @@ -22,7 +22,8 @@ func init() {
panic(err)
}
}
func (bi BigInt) Convert(i *big.Int) error {
func (bi *BigInt) Convert(i *big.Int) error {
fmt.Println(i.Text(10))
return bi.CreateFromString(i.Text(10), 10)
}

Expand Down

0 comments on commit 12e9dbf

Please sign in to comment.