1
1
mirror of https://github.com/wader/fq.git synced 2024-11-30 09:58:13 +03:00
fq/internal/mathextra/big.go
Mattias Wadman edad481878 num,mathextra: Rename num package to mathextra
Think it makes more sense
2022-01-15 19:00:42 +01:00

14 lines
258 B
Go

package mathextra
import "math/big"
var BigIntOne = big.NewInt(1)
func BigIntSetBytesSigned(n *big.Int, buf []byte) *big.Int {
n.SetBytes(buf)
if len(buf) > 0 && buf[0]&0x80 > 0 {
n.Sub(n, new(big.Int).Lsh(BigIntOne, uint(len(buf))*8))
}
return n
}