Skip to content

Instantly share code, notes, and snippets.

@russmack
Created June 23, 2015 19:23
Show Gist options
  • Save russmack/535aa6ec9275b0ec2022 to your computer and use it in GitHub Desktop.
Save russmack/535aa6ec9275b0ec2022 to your computer and use it in GitHub Desktop.
Editing bits.
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