mirror of
https://github.com/wader/fq.git
synced 2024-12-02 12:45:53 +03:00
14 lines
255 B
Go
14 lines
255 B
Go
package mathex
|
|
|
|
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
|
|
}
|