github.com/annchain/OG@v0.0.9/tests/bit_test/bit_test.go (about)

     1  package bit_test
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/annchain/OG/arefactor/og/types"
     6  	"testing"
     7  )
     8  
     9  func TestBits(t *testing.T) {
    10  
    11  	b := types.RandomHash().ToBytes()
    12  	k := 4
    13  
    14  	//for j=:0;j<100;j++ {
    15  	//
    16  	//}
    17  	mask := byte(1 << uint(k-1))
    18  	p := b[2] & mask
    19  	if p > byte(0) {
    20  		fmt.Println(true)
    21  	} else {
    22  		fmt.Println(false)
    23  	}
    24  	fmt.Printf("\n%b  %b %b", b[2], p, mask)
    25  }