Created
June 23, 2015 19:23
-
-
Save russmack/535aa6ec9275b0ec2022 to your computer and use it in GitHub Desktop.
Editing bits.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/big" | |
) | |
/* | |
1 | |
10 | |
11 | |
100 | |
101 | |
110 | |
111 | |
1000 | |
1001 | |
1010 | |
1011 - 11 | |
*/ | |
func main() { | |
x := new(big.Int) | |
x.SetInt64(11) | |
fmt.Println(x) // 11 | |
b := x.Bit(1) | |
fmt.Println(b) // 1 | |
c := x.SetBit(x, 1, 0) | |
fmt.Println(c) // 9 | |
b = x.Bit(1) | |
fmt.Println(b) // 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment