Skip to content

Commit a90e645

Browse files
mobile: added constructor for big int (#21597)
* mobile: added constructor for big int * mobile: tiny nitpick
1 parent 420b786 commit a90e645

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎mobile/big.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ func NewBigInt(x int64) *BigInt {
3535
return &BigInt{big.NewInt(x)}
3636
}
3737

38+
// NewBigIntFromString allocates and returns a new BigInt set to x
39+
// interpreted in the provided base.
40+
func NewBigIntFromString(x string, base int) *BigInt {
41+
b, success := new(big.Int).SetString(x, base)
42+
if !success {
43+
return nil
44+
}
45+
return &BigInt{b}
46+
}
47+
3848
// GetBytes returns the absolute value of x as a big-endian byte slice.
3949
func (bi *BigInt) GetBytes() []byte {
4050
return bi.bigint.Bytes()

0 commit comments

Comments
 (0)