init: v1.0.0
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
//go:build !go1.15
|
||||
// +build !go1.15
|
||||
|
||||
package gmath
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// FillBytes fill the buf with the abs of a in big-endian with zero extention.
|
||||
// if buf is two short, then return error, while Big.Int's FillBytes panic
|
||||
func FillBytes(a *big.Int, buf []byte) error {
|
||||
if (a.BitLen()+7)/8 > len(buf) {
|
||||
return ErrBufTooShort
|
||||
}
|
||||
|
||||
b := ToNBytes(a, len(buf))
|
||||
copy(buf, b)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user