MCPcopy Create free account
hub / github.com/0xsequence/czip / isPow2

Function isPow2

compressor/utils.go:35–58  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

33}
34
35func isPow2(b []byte) int {
36 seen1 := false
37 val := 0
38
39 for _, byteVal := range b {
40 for ii := 7; ii >= 0; ii-- {
41 bit := (byteVal >> ii) & 1
42 if bit == 1 {
43 if !seen1 {
44 seen1 = true
45 continue
46 } else {
47 return -1
48 }
49 } else {
50 if seen1 {
51 val++
52 }
53 }
54 }
55 }
56
57 return val
58}
59
60func isPow10(b []byte) int {
61 num := big.NewInt(0).SetBytes(b)

Callers 1

EncodeWordOptimizedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected