1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 00:57:15 +03:00
fq/internal/mathx/big.go
Mattias Wadman bf7fa07c41 fq: Use go 1.20 and cleanup
Also rename *ex packages to *x
2024-04-01 19:14:10 +02:00

14 lines
254 B
Go

package mathx
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
}