add big.Int Lsh and Rsh and test it

This commit is contained in:
tsingbx
2024-08-08 13:33:14 +08:00
parent 289caa7cc2
commit df37f80c8e
2 changed files with 60 additions and 100 deletions

View File

@@ -40,7 +40,7 @@ func neg() {
fmt.Println("value: ", big.NewInt(0).Neg(big.NewInt(0)))
}
func main() {
func calc() {
a := big.NewInt(64)
b := big.NewInt(-52)
c := big.NewInt(54)
@@ -50,3 +50,14 @@ func main() {
e := big.NewInt(4)
fmt.Println("value:", d.Mul(d, e))
}
func bitop() {
a := big.NewInt(4)
fmt.Println("value:", a.Lsh(a, 1))
b := big.NewInt(16)
fmt.Println("value:", b.Rsh(b, 2))
}
func main() {
bitop()
}